The CreatorCon Call for Content is officially open! Get started here.

Access complex named JSON object

Arka Banerjee
Kilo Guru
  • Hi All,

 

I need to fetch the value of a complex named json object. Could you please help on the same.

 

R[

{

"a:b:c:d"

{

"xyz" : abc

}

}

 

Can someone help me with how I can fetch the value of "xyz" object from here. Since a:b:c:d is a complex name, I cant directly dotwalk.

 

8 REPLIES 8

-O-
Kilo Patron

That is not a valid code and not a valid JSON.

Can you post the actual code or JSON that you are trying to read?

Hi,

 

PFB JSON

 

{
"Resources": [
{
"urn:ietf:params:scim:schemas:sailpoint:1.0:User": {
"personID": "856247"
}
}
]
}

 

Can you please help in how I can fetch the personID value from this.

Maddysunil
Kilo Sage

@Arka Banerjee 

That does'nt seems to be valid JSON but you can try with below

 

var jsonObject = {
    "a:b:c:d": {
        "xyz": "abc"
    }
};

var valueOfXYZ = jsonObject["a:b:c:d"]["xyz"];
gs.info("Value of 'xyz': " + valueOfXYZ);

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks

Hi Sunil,

 

PFB JSON

 

{
"Resources": [
{
"urn:ietf:params:scim:schemas:sailpoint:1.0:User": {
"personID": "856247"
}
}
]
}

 

Can you please help in how I can fetch the personID value from this.