Pull data from JSON array and save it into string field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2017 05:34 PM
Hi,
We are doing integration to 3rd party system using web services and data will be getting in JSON format. I can pull data from each field but i have an JSON array from the list. So, i want to save the array data to string field in service now.
Data:
{
"ServiceTeam": null,
"Software": null,
"SoftwareVersion": null,
"Source": "MDS",
"IPAddresses": [
{
"Name": null,
"Number": "45231",
"Description": "Intel Ethernet Connection",
"IPAddress": "xx:xx:xx:xx:xx:xx"
},
{
"Name": null,
"Number": "45232",
"Description": "Async Adapter",
"IPAddress": "xx:xx:xx:xx:xx:xx"
},
{
"Name": null,
"Number": "45233",
"Description": "Intel Dual Band Wireless",
"IPAddress": "xx:xx:xx:xx:xx:xx"
}
]
},
In this above example i want to save the data from "IPAddresses": [ to end of an array in the string field. Any suggetions
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2017 09:06 PM
Based on the Structure, the IPAddresses in the Data is an array of objects. You can try to access it by:
<Main object>.<sub object>[Index of data].<property>
Data.IPAddresses[0].Name
Data.IPAddresses[1].Name
Data.IPAddresses[2].Name
something like this.
Hope this helps.
a.c.manlangit
ServiceNow Developer Philippines
You may mark this as helpful or correct answer depending on the impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2017 09:39 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2017 10:33 PM
I think this can be due to the character you used. the colon(':') in the ip address, your format is "xx:xx:xx:xx", it should be in "xx.xx.xx.xx", just a hunch.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2017 10:59 PM
Hi Ariestotle,
Tried the beolw thing and it works
var myData=
{
"ServiceTeam":null ,
"Software": null,
"SoftwareVersion":null ,
"Source": "MDS",
"IPAddresses":[]
}
Then inorder to push the data to IP Address use this :
myData.IPAddresses.push({
"Name": null,
"Number": "45231",
"Description": "Intel Ethernet Connection",
"IPAddress": "xx:xx:xx:xx:xx:xx"
});
myData.IPAddresses.push({
"Name": null,
"Number": "45232",
"Description": "Async Adapter",
"IPAddress": "xx:xx:xx:xx:xx:xx"
});
myData.IPAddresses.push({
"Name": null,
"Number": "45233",
"Description": "Intel Dual Band Wireless",
"IPAddress": "xx:xx:xx:xx:xx:xx"
});
post me your feedback
Please Hit ✅Correct, âÂ��Helpful, or ��Like depending on the impact of the response
Have a lovely day ahead
Regards,
Divya Mishra
