I know, all of the previous answers are insightful to your question. I had too like you this confusion just one minute before finding this SO thread. After reading some of the answers, here is what I get: JSONObject 是一个类似于 JSON 的对象,可以表示为数组中的一个元素 JSONArray。换句话说,JSONArray 可以包含一个(或多个) JSONObject。
1. Arrays in JSON are used to organize a collection of related items
(Which could be JSON objects)
2. Array values must be of type string, number, object, array, boolean or null
3. Syntax:
[ "Ford", "BMW", "Fiat" ]
4. JSON arrays are surrounded by square brackets [].
**Tip to remember** : Here, order of element is important. That means you have
to go straight like the shape of the bracket i.e. straight lines.
(Note :It is just my logic to remember the shape of both.)
5. Order of elements is important. Example: ["Ford","BMW","Fiat"] is not
equal to ["Fiat","BMW","Ford"]
6. JSON can store nested Arrays that are passed as a value.
JSON Object
1. JSON objects are written in key/value pairs.
2. Keys must be strings, and values must be a valid JSON data type (string, number,
object, array, boolean or null).Keys and values are separated by a colon.
Each key/value pair is separated by a comma.
3. Syntax:
{ "name":"Somya", "age":25, "car":null }
4. JSON objects are surrounded by curly braces {}
Tip to remember : Here, order of element is not important. That means you can go
the way you like. Therefore the shape of the braces i.e. wavy.
(Note : It is just my logic to remember the shape of both.)
5. Order of elements is not important.
Example: { rollno: 1, firstname: 'Somya'}
is equal to
{ firstname: 'Somya', rollno: 1}
6. JSON can store nested objects in JSON format in addition to nested arrays.