web stats
JSON object within a JSON object - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 01-22-2019, 10:14 AM
gojoshi gojoshi is offline
OBX.1 Kenobi
 
Join Date: Jul 2013
Posts: 42
gojoshi is on a distinguished road
Default 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"

}
}
Reply With Quote
  #2  
Old 01-23-2019, 03:07 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,005
agermano is on a distinguished road
Default

Code:
{
    "FirstName": "Homer",
    "MiddleName": "Einstein",
    "LasttName": "Simpson",
    "Religion": {
        "Name": "Unknown",
        "Age": "1Mil_Years"
    }
}
Reply With Quote
  #3  
Old 01-25-2019, 04:33 AM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 835
siddharth is on a distinguished road
Default

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!
Reply With Quote
Reply

Tags
json

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 06:03 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation