Json Parse Format

This documentation illustrates how to parse the JSON path.

Type 1 JSON Objects

JSON objects are wrapped in curly braces. Inside the object, we can list any number of key-value pairs, separated by commas:

// Some code
{
    "firstName": "John",
    "lastName": "Doe",
    "email": "john.doe@example.com",
    "age": 45,
    "weight": 67,
    "admin": true
}

Parse: Want to parse the name: root.firstName Want to parse the age: root.age Want to parse the full response: root

Type 2 JSON Arrays

JSON arrays are wrapped in square brackets. Inside an array, we can declare any number of objects, separated by commas:

// Some code
[
    {
        "name": "Jason",
        "gender": "M",
        "age": 27
    },
    {
        "name": "Rosita",
        "gender": "F",
        "age": 23
    },
    {
        "name": "Leo",
        "gender": "M",
        "age": 19
    }
]

Parse: Want to parse the name: root[*].name Want to parse the age: root[*].age Want to parse the full response: root

Type 3 Nesting Objects & Arrays

JSON can store nested objects and arrays as values assigned to keys. It is very helpful for storing different sets of data in one file:

// Some code
{
    "name": "Jason Ray",
    "profession": "Software Engineer",
    "age": 31,
    "address": {
        "city": "New York",
        "postalCode": 64780,
        "Country": "USA"
    },
    "languages": ["Java", "Node.js", "JavaScript", "JSON"],
    "socialProfiles": [
        {
            "name": "Twitter",
            "": "https://twitter.com"
        },
        {
            "name": "Facebook",
            "link": "https://www.facebook.com"
        }
    ]
}

Parse: Want to parse the name: root[*].name Want to parse the age: root[*].age Want to parse the city: root.address.city Want to parse the Java: root.languages.[0] Want to parse the link: root.socialProfiles[*].link Want to parse the full response: root

Note: * means the array index.

Last updated