开发者

encoding PHP array to Javascript (JSON)

how do I get [{}] in JSON? If I encode arr开发者_JAVA技巧ay() in PHP, the JSON result is []. What is [{}] in JS anyway?

Thanks


you can use: array(new stdClass) which when json_encoded, should end up to be [{}]

To answer your second question of "what is [{}] anyway?", well it is simple:

it's an array, whose only element is an object with no members in it.


[{}] is an array containing an object. JSON is an object and you can have a JSONArray within it and more objects within that. Don't overthink the data structure :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜