Access complex named JSON object
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 01:25 PM - edited 04-18-2024 01:27 PM
- 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 02:32 PM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 01:56 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 07:46 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 01:56 AM
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.