Question

Need help Json Transfer


Hi All , i am looking to transfer a json file . our json file is having multiple level of Array.

below is the structure of my json file

From the above data , I am looking to extract id, long-name and vlan-id.

can someone please help me to achieve this .


11 replies

Userlevel 4
Rather than posting screenshots, could you please post some sample JSON?
Userlevel 4

The attached template will get you the long-name and the vlan-id, where available. Not sure what you mean by id, however.

JSON query:

json["controller:devices"]["device"][*]["interface:interfaces"]["interface"][*]

Remember to expose the list "interface-ext:efp-service-instances.efp-service-instance{}.vlan-id" and send it through a ListExploder to get all the vlan-ids per long-name.

multi-array-json.fmwt

The attached template will get you the long-name and the vlan-id, where available. Not sure what you mean by id, however.

JSON query:

json["controller:devices"]["device"][*]["interface:interfaces"]["interface"][*]

Remember to expose the list "interface-ext:efp-service-instances.efp-service-instance{}.vlan-id" and send it through a ListExploder to get all the vlan-ids per long-name.

multi-array-json.fmwt

Thanks for your response @david_r. I was using kind of similar approach , but that seem to be giving me only vlan-id. my problem here is that id (device) , long-name and vlan-id , all are different level json object , and a device can have multiple interface and each interface can have multiple zero or more vlan-id . i need a final feature attribute that give me id=>long-interface=>vlan-id

0684Q00000ArMrfQAF.png

please let me know if i am missing something here. when i added long-name in the above transformer , it only give me the vlan-id and does not give long-name.
Userlevel 4
Thanks for your response @david_r. I was using kind of similar approach , but that seem to be giving me only vlan-id. my problem here is that id (device) , long-name and vlan-id , all are different level json object , and a device can have multiple interface and each interface can have multiple zero or more vlan-id . i need a final feature attribute that give me id=>long-interface=>vlan-id

please let me know if i am missing something here. when i added long-name in the above transformer , it only give me the vlan-id and does not give long-name.
I just updated my reply, could it be that this fixes the issue?
I just updated my reply, could it be that this fixes the issue?
How about adding the id which is at device level ?

 

 

Userlevel 4
How about adding the id which is at device level ?

 

 

I would shorten the JSON query up to the device level and then add ListExploders as necessary. I agree it's a bit messy...

The attached template will get you the long-name and the vlan-id, where available. Not sure what you mean by id, however.

JSON query:

json["controller:devices"]["device"][*]["interface:interfaces"]["interface"][*]

Remember to expose the list "interface-ext:efp-service-instances.efp-service-instance{}.vlan-id" and send it through a ListExploder to get all the vlan-ids per long-name.

multi-array-json.fmwt

 

Thanks David , to be honest that is where i was stuck , it appears to work at one level but when we have multi level of reference , i am having trouble. I have used the query json[*]["device"][*] at device level , expose the attribute - expose the attribute id and interface:interfaces.interface{} . then use list exploder to get interfaces for each devices , so far so good , but when i try to use another list exploder to get the vlan-id , it does not seem to work , any suggestion or if you can share some sample workbench that would be great.
Userlevel 4

Try the attached workspace that shows how to get the device id, interface long-name with the associated instance vlan-id's.

multi-array-json.fmwt

 

Thanks David , to be honest that is where i was stuck , it appears to work at one level but when we have multi level of reference , i am having trouble. I have used the query json[*]["device"][*] at device level , expose the attribute - expose the attribute id and interface:interfaces.interface{} . then use list exploder to get interfaces for each devices , so far so good , but when i try to use another list exploder to get the vlan-id , it does not seem to work , any suggestion or if you can share some sample workbench that would be great.
@david_r , this is what i have tried , it appears to give me the mapping for device and interface , but not able to give anything with second list exploder. am i missing something here.

Userlevel 4

 

Thanks David , to be honest that is where i was stuck , it appears to work at one level but when we have multi level of reference , i am having trouble. I have used the query json[*]["device"][*] at device level , expose the attribute - expose the attribute id and interface:interfaces.interface{} . then use list exploder to get interfaces for each devices , so far so good , but when i try to use another list exploder to get the vlan-id , it does not seem to work , any suggestion or if you can share some sample workbench that would be great.
Have a look at the template I posted separately above.

Try the attached workspace that shows how to get the device id, interface long-name with the associated instance vlan-id's.

multi-array-json.fmwt

 

Great !! thanks David . this was helpful. i have tried below and that also gave me the desired result. Thanks a lot for your help.

Reply