-1

how do I get [{}] in JSON? If I encode array() in PHP, the JSON result is []. What is [{}] in JS anyway?

Thanks

1
  • [{}] is an array containing a single empty object. Commented Sep 25, 2011 at 20:04

2 Answers 2

4

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.

0
1

[{}] 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.