Importing CIs Using a Nested JSON Payload From a Data Source

Mike I2
Giga Guru

Hi, 

I've a challenge in retrieving devices and software records from a third party inventory tool - Cisco's EPNM,  and creating/updating CIs from it. 

 

I'm intending to use a data source using REST to retried the payload, however the JSON we're receiving is very nested (see attached): for example a router will also contain shell CIs for chassis', network adapter's, etc. I would like to be able to extract each CI from the payload and import them into corresponding tables but have so far not had any success beyond creating CI in the Hardware table. Any help would be greatly appreciated. 

 

Thanks

 

1 ACCEPTED SOLUTION

Mike I2
Giga Guru

The main issue we found was with how ServiceNow handles nested JSON with their JSON paths, To work around it, I had to create two data sources using different paths to pull out all of the data. The following worked quite well;

 

  1. create a JSON Parser action step similar to https://docs.servicenow.com/bundle/tokyo-application-development/page/administer/flow-designer/refer...
  2. create two REST data sources, one to parse the main node and a 2nd to parse the equipment list. Both data sources need to use the parser action step.
  3. Using ETL, created two robust transform maps to transform that data and push it through IRE. 

 

View solution in original post

2 REPLIES 2

thomaskennedy
Tera Guru

It sounds like you might be unsure how to drill down into the data. Here's a quick first pass at that:

 

function scanFile(){
	var data = require('./data.json'); // parsed data
	data = data['nd.node'];
	data = data[0];
	data = data['nd.equipment-list'];
	data = data['eq.equipment'];
	data.forEach( e => console.log(e['fdtn.description']) );
	
}

scanFile();

PS C:\temp\ciscodata> node scan.js
Cisco CSR1000V Chassis
Cisco CSR1000V Embedded Services Processor
QFP 0 of module F0
Cisco CSR1000V Route Processor
CPU 0 of module R0

Mike I2
Giga Guru

The main issue we found was with how ServiceNow handles nested JSON with their JSON paths, To work around it, I had to create two data sources using different paths to pull out all of the data. The following worked quite well;

 

  1. create a JSON Parser action step similar to https://docs.servicenow.com/bundle/tokyo-application-development/page/administer/flow-designer/refer...
  2. create two REST data sources, one to parse the main node and a 2nd to parse the equipment list. Both data sources need to use the parser action step.
  3. Using ETL, created two robust transform maps to transform that data and push it through IRE.