简体   繁体   中英

What does it mean in JSON

{
    "messageshow": [
        {
            "message_id": "497",
            "message": "http://flur.p-sites.info/api/messages/voice/1360076234.caff",
            "message_pic": "<UIImage: 0xa29e160>",
            "uid": "44",
            "created": "4 hours ago",
            "username": "pari",
            "first_name": "pp",
            "last_name": "pp",
            "profile_pic": "http://flur.p-sites.info/api/uploads/13599968121.jpg",
            "tag_user": {
                "tags": [
                    {
                        "message": "false"
                    }
                ]
            },
            "boos_list": {
                "booslist": [
                    {
                        "message": "false"
                    }
                ]
            },
            "aplouds_list": {
                "aploudslist": [
                    {
                        "message": "false"
                    }
                ]
            },
            "total_comments": 0,
            "total_boos": 0,
            "total_applouds": 0
        },
        {
            "message_id": "496",
            "message": "http://flur.p-sites.info/api/messages/voice/1360076182.caff",
            "message_pic": "<UIImage: 0xa3b0610>",
            "uid": "44",
            "created": "4 hours ago",
            "username": "pari",
            "first_name": "pp",
            "last_name": "pp",
            "profile_pic": "http://flur.p-sites.info/api/uploads/13599968121.jpg",
            "tag_user": {
                "tags": [
                    {
                        "message": "false"
                    }
                ]
            },
            "boos_list": {
                "booslist": [
                    {
                        "message": "false"
                    }
                ]
            },
            "aplouds_list": {
                "aploudslist": [
                    {
                        "message": "false"
                    }
                ]
            },
            "total_comments": 0,
            "total_boos": 0,
            "total_applouds": 0
        }
    ]
}

In this JSON all value are coming in "" quotes, but few tags are coming without any quotes what does it indicate ?

JSON Display value without quote it consider as Numeric value..

For JSON beginner :

JSON Syntax Rules

JSON syntax is a subset of the JavaScript object notation syntax:

  • Data is in name/value pairs
  • Data is separated by commas
  • Curly braces hold objects
  • Square brackets hold arrays

JSON data is written as name/value pairs.

A name/value pair consists of a field name (in double quotes), followed by a colon, followed by a value:

"firstName" : "John"

This is simple to understand, and equals to the JavaScript statement:

firstName = "John"

JSON values can be:

  • A number (integer or floating point)
  • A string (in double quotes)
  • A Boolean (true or false)
  • An array (in square brackets)
  • An object (in curly brackets)
  • null

JSON Objects :

JSON objects are written inside curly brackets,

Objects can contain multiple name/values pairs:

{ "firstName":"John" , "lastName":"Doe" }

This is also simple to understand, and equals to the JavaScript statements:

firstName = "John"
lastName = "Doe"

JSON Arrays : JSON arrays are written inside square brackets.

An array can contain multiple objects:

{
"employees": [
{ "firstName":"John" , "lastName":"Doe" }, 
{ "firstName":"Anna" , "lastName":"Smith" }, 
{ "firstName":"Peter" , "lastName":"Jones" }
]
}

In the example above , the object "employees" is an array containing three objects. Each object is a record of a person ( with a first name and a last name ).

This is Basic of JSON

For more understanding refere this site. Thanks

The tags which are without double quotes are integer values or Boolean Values or NULL.

The tags which are starting with [] square brackets are Arrays.

The tags which are starting with {} is JSON inside a attribute/value.

That depends on the type of the value. If the value is an numerical type its WITHOUT the quotes.
If it is no numerical type it's WITH the quotes (for example Strings , like most in your example).

In addition to strings JSON supports numerical values. So in this case the values without quotes are simply considered numbers.

They are numeric values. As per the JSON docs:

A value can be a string in double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM