美文网首页Java
Json Object VS Json Array

Json Object VS Json Array

作者: JaedenKil | 来源:发表于2021-09-22 18:03 被阅读0次

    Easiest understanding:

    When syntax is {} then this is JsonObject
    When syntax is [] then this is JsonArray
    

    JSONObject:

    • Contains named values (key->value pairs, tuples or whatever you want to call them)
      like {ID : 1}
    • Order of elements is not important
      a JSONObject of {id: 1, name: 'B'} is equal to {name: 'B', id: 1}.

    JSONArray:

    • Contains only series values
      like [1, 'value']
    • Order of values is important
      array of [1,'value'] is not the same as ['value',1]

    Additional info:
    We can use the Array first approach if we intend to store a set of values with no need to identify uniquely.

    [
       {
          "Employees":[
             {
                "Name":"Alan",
                "Children":[
                   "Walker",
                   "Dua",
                   "Lipa"
                ]
             },
             {
                "Name":"Ezio",
                "Children":[
                   "Kenvey",
                   "Connor",
                   "Edward"
                ]
             }
          ]
       }
    ]
    

    相关文章

      网友评论

        本文标题:Json Object VS Json Array

        本文链接:https://www.haomeiwen.com/subject/jgdggltx.html