echo json_encode($testArray);
The thing is, it encodes every array element the way I want except the last one. Take a look at what I get:
[
{
"x": "..",
"x": "..",
"x": "..",
}
]"x": "..","x": "..","x": "
As you can see, the last element format is just wrong. Its outside Json object and the format is messed up. Not sure what could cause this. I checked array (which I pass for encoding) and its fine. Any ideas?
Found the solution myself. Maybe someone will find it useful:
json_encode($array, JSON_HEX_QUOT | JSON_HEX_TAG);