Announcement

Collapse
No announcement yet.

JSON object within a JSON object

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • JSON object within a JSON object

    Hello Everyone,

    How do you create an object inside a JSON object..

    For example if you have a JSON object with the name of 'jsonObject' , how do you declare another object that will be an object of 'jsonObject' .. lets say the other objects name is 'Religion' that go into 'jsonObject' like this:

    {
    "FirstName": "Homer",
    "MiddleName": "Einstein",
    "LasttName": "Simpson"
    {
    "Religion.Name":"Unknown",
    "Religion.Age" ""1Mil_Years"

    }
    }

  • #2
    Code:
    {
        "FirstName": "Homer",
        "MiddleName": "Einstein",
        "LasttName": "Simpson",
        "Religion": {
            "Name": "Unknown",
            "Age": "1Mil_Years"
        }
    }

    Comment


    • #3
      The key is to start from inside to out.

      if your intended structure is {"a":{"b":1"}}

      I would first create the inside object like

      obj2={}
      obj2.b=1;

      and then add it to outside object; like this

      obj1 ={}
      obj1.a = obj2;
      HL7v2.7 Certified Control Specialist!

      Comment

      Working...
      X