
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Extracting JSON data from a file
Hello team, we have a json file with three loops Po, Delivery and Items,
we manage to extract data from the file using the tExtractjsonCompoenent (XPATH or JSONPATH) if the files contains the the three loops
however we are facing this issues , i will try to explain in the following exemple
i'am reading a file named data.json which contain
- 2 PO (first loop level )
- 2 Delivery (seocnd loop level ) - ---> 1 delivery in the first PO
----> 1 delivery in the second PO
- 2 item (third loop level ) ------> 2 item in the first delivery of the the first PO
------> the second PO does not include any item inside the the delivery level
we manage to read the first PO successfully as shown in the job however we couldn't read the second PO beacasue it does not contain
the item level in the delivery so how can we read a complex Json file with optional level (which means that the item level could exist in one PO
but not in the seocnd or in the thrid , it is an optinal element
this is the configuration that we are doing in tExtractJson
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I know this isn't ideal, but you can create 3 JSON inputs, each with the 3 JSON arrays and then merge them together

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @wmasmoudi,
You can try by using three tExtractJSONField components one-by-one like this and expand your JSON fields by extracting them.
For example: In your case, you can first extract PO [ ..., Delivery,...] ------> then expand the Delivery [..., item,...] ---------> then expand Item.
After that, you have fully expanded JSON with all the elements.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi , thanks for your answer , actually we tried that at the the beginning but the result was the same
