8.24.2012

Difference between Json Array and Json Object

Difference between Json Array and Json Object

S.No
Json Array Json Object
1 A JSONArray is an ordered sequence of values. A JSONObject is an unordered collection of name/value pairs.
2
Its external text form is a string wrapped in square brackets with commas separating the values.
Its external form is a string wrapped in curly braces with colons between the names and values, and commas between the values and names.
Example for Json Array

[        {"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"},
        {"ircEvent": "PRIVMSG", "method": "deleteURI", "regex": "^delete.*"},
        {"ircEvent": "PRIVMSG", "method": "randomURI", "regex": "^random.*"}
] 
 
Example for Json Object

{"bindings": [
        {"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"},
        {"ircEvent": "PRIVMSG", "method": "deleteURI", "regex": "^delete.*"},
        {"ircEvent": "PRIVMSG", "method": "randomURI", "regex": "^random.*"}
    ]
};

No comments:

Post a Comment