Insert json to importset table

pratiksha5
Mega Sage

I am creating a data source using load by script option. I am able to retrive the data but not able to correctly put it in the import set table. 

 

The Json looks like this : 

 

{
"data": {
"type": "io",
"id": "123",
"attributes": {
"ipAddresses": [
"101.10.113.95"
],
"deviceName": "Device@101.10.113.95",
"deviceType": "unknown",
"makeModel": null,
 
},
"relationships": {
"tenant": {
"data": {
"type": "tenant",
"id": "123",
"attributes": {
"domainPrefix": "abc"
}
}
},
 
Code : 
var parsedResponse = JSON.parse(responseBody);
            var deviceData = parsedResponse.data;
 
 
            //Loop through each record and insert data into import set table
 
            for (var eachDevice in deviceData) {
var map ={
u_type: deviceData[eachDevice].type, //works fine
u_id:deviceData[eachDevice].id, //works fine
u_deviceName:deviceData[eachDevice]['attributes'].deviceName //not working
 
};           
I have tried multiple ways but not getting the values inserted in the import set. Please help 
@Ravi Chandra_K @AnkurBawiskar

1 ACCEPTED SOLUTION

Found the solution  u_attributes_devicename: deviceData[eachDevice]['attributes']['deviceName']

I have to write the name of the import set column name plus access the array in given format. 

View solution in original post

7 REPLIES 7

@pratiksha5 can you send me your entire JSON structure once again please?

added response to the question. 

Found the solution  u_attributes_devicename: deviceData[eachDevice]['attributes']['deviceName']

I have to write the name of the import set column name plus access the array in given format.