JSON root element

前端 未结 3 532
走了就别回头了
走了就别回头了 2020-12-29 05:50

Does JSON require a root element as in XML case. As far as I know this is a valid JSON string.

{
    \"email\":[
        {
            \"type\":\"home\",
            


        
3条回答
  •  没有蜡笔的小新
    2020-12-29 06:17

    According to the modified Backus-Naur-Form on the right side pane of http://json.org/ the root element of a JSON data structure can be any of these seven types/values:

    Object
    Array
    String
    Number
    true
    false
    null
    

    Examples

    So all of the following examples are valid JSON root elements:

    {
      "name": "Jpsy",
      "age": 99
    }
    
    [ 1, 2, "three", 4, 5 ]
    
    "abcdefg"
    
    123.45
    
    true
    
    false
    
    null
    

提交回复
热议问题