8
Reply

How to access JSON object in JavaScript

ashish shinde

ashish shinde

6y
2.8k
4
Reply

    let consider you have Json object like: var objectValue= { "name": "mkyong", "age": 30, "address": { "streetAddress": "88 8nd Street", "city": "New York" }, "phoneNumber": [ { "type": "home", "number": "111 111-1111" }, { "type": "fax", "number": "222 222-2222" } ] } Ans:-

    Json objects are written in ket/value pairs.
    Example:

    1. { "name":"John", "age":30, "car":null }

    we can fetch above object by key value.
    When we will POST it through ajax call
    we should stringyfy it like followings

    1. JSON.stringify({ "name":"John", "age":30, "car":null })

    let consider you have Json object like: var objectValue= { "name": "mkyong", "age": 30, "address": { "streetAddress": "88 8nd Street", "city": "New York" }, "phoneNumber": [ { "type": "home", "number": "111 111-1111" }, { "type": "fax", "number": "222 222-2222" } ] } Ans:-

    JSON.stringify(obj)"obj" is json object.