Each item in the allergen list becomes its own JSON object.
Each item in the doc_type and tests list get "converted to boolean". That is to say, if the doc_type list contains Allergist then the resulting JSON object would contain diagnosed_by_allergist: true. If the phrase "Allergist" is not present then it's not necessary for the resulting object to contain diagnosed_by_allergist: false. (This is more of a conditional operation than a data conversion).
In the original JSON, all the subsequent data applies to each allergen. So, for example, diagnosis_age applies the same to the resulting Peanuts, Egg, and Milk JSON objects.
What JOLT transform spec can I use to "flatten" the allergen list into individual objects and conditionally present fields?
I need to apply a JOLT transform to some JSON.
Example input JSON is...
The expected output would be:
How can I apply two transforms to this JSON?
diagnosed_by_allergist: true
. If the phrase "Allergist" is not present then it's not necessary for the resulting object to containdiagnosed_by_allergist: false
. (This is more of a conditional operation than a data conversion).In the original JSON, all the subsequent data applies to each allergen. So, for example,
diagnosis_age
applies the same to the resultingPeanuts
,Egg
, andMilk
JSON objects.What JOLT transform spec can I use to "flatten" the allergen list into individual objects and conditionally present fields?