Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (800 points)

After having a short look at Google I found this link that describes the difference, yet from a syntax point of view.

When would one be preferred over the other in a programming scenario?

1 Answer

0 votes
by (13.2k points)

JSON Array

Arrays in JSON are used to organize the objects which are related ( which can be JSON objects). They are surrounded by a set of square brackets [ ] and the order of elements is important in case of JSON arrays. ( any change would make it different array altogether)

Syntax: [ "SpaceX", "NASA", "ISRO" ]

JSON Objects

A JSON object is used to contain key/value pairs when they are related to one particular item. They are surrounded by a set of curly brackets { } and the order of elements is not important in case of JSON objects.

Example:

 {ID: 72, firstname: 'Alex'}

 is equal to

 {firstname: 'Alex', ID: 72}

Related questions

0 votes
1 answer
asked Oct 17, 2019 in Java by Shubham (3.9k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Aug 15, 2019 in Java by Krishna (2.6k points)
0 votes
2 answers

Browse Categories

...