Is there any way to encode a PHP array (or any other similar PHP object) into JSON while having identical keys for a JSON array?
Here is an example:
{"categories" : [ {"key": "data1"}, {"key": "data2"}, {"key": "data3" } ] }
Note that the "categories" object is an array that can be simply parsed with a for loop. However, in PHP, it is impossible it seems to have identical keys in an associative array. So I can't have the structure above as my result from json_encode, and I have to have "key1", "key2", "key3", which prevents me from simply parsing it with a for loop in Javascript.
EDIT: Fixed JSON syntax EDIT2: All data is different. Keys are identical.
{"categories" : [ {"key": "data"},{ "key": "data"},{"key": "data"} ] }
{"cat":{"key":["item1","item2"]}}