I've been working with C2 for a couple weeks now. Yesterday I ran into an issue trying to parse a JSON file into an array. It works fine with the Dictionary object, but I don't seem to be able to get the formatting right with an Array. Now, I already read through this thread:
But I'm not trying to parse "pure" JSON and I have access and ability to modify the JSON file. Here's the code I'm using (with some irrelevant data):
$name = 'Ainx';
$level = 3;
$experience = 56;
$gold = 244;
//Build 2nd dimension
$arr_names = array('name' => $name);
$arr_levels = array('level' => $level);
$arr_experiences = array('experience' => $experience);
$arr_golds = array('gold' => $gold);
//Build 1st dimension
$arr_data = array($arr_names, $arr_levels, $arr_experiences, $arr_golds);
$arr = array('c2array' => TRUE, 'size' => array(4, 2, 1), 'data' => $arr7);
The code prints fine and I can parse and retrieve it with .getAjax and so on... I can also retrieve that in C2, but when I try to put it into a C2 array, it does nothing. Am I building this array incorrectly? I included C2 specific tags.
Here's the example php file above.
Using a dictionary works:
$dic_data = array('name' => $name, 'level' => $level, 'experience' => $experience, 'gold' => $gold);
$dic = array('c2dictionary' => TRUE, 'data' => $dic_data);
I'm able to import that into a dictionary in C2 without a hitch, but I'd like to be able to use arrays, because Dictionary is a tad too primitive for what I need. I thought about using two Dictionaries instead when I couldn't get the array to work, but that's a bit silly...
I'm using the AJAX Request, AJAX On completed and Array Load events; all the basic AJAX/Array stuff covered in the tutorials and the manual on the site. I think the issue is with how I'm formatting PHP which now that I think about it might not be for this forum :<
Any help would be appreciated.