Forum Discussion
Yes, I’m not seeing any nested arrays in the JSON input or output you posted, except for the one where you’re saying that this isn’t what you want. Try posting the input and desired output with the Preformatted Text feature in the editor (icon looks like </>). That will also prevent the double quotes from getting inserted as left/right versions like in English text, which is invalid JSON.
[
{"name": "value"},
{"name", "value"}
]
- MarotReply5 years agoNew Contributor II
I haven’t yet found a solution, so yes.
Also here are the formatted JSONS:Received JSON:
{ "Property1":"value1", "Property2":"value2", "Property3":"value3", "Subarray":[ { "SubProperty1":"subValue1", "SubProperty2":"SubValue2", "SubProperty3":"SubValue3" }, { "SubProperty1":"subValue4", "SubProperty2":"SubValue5", "SubProperty3":"SubValue6" } ] }Should be Produced JSON:
{ "Prop1":"value1", "Prop2":"value2", "MyArray":[ { "SubProp1":"subValue1", "SubProp2":"SubValue2", }, { "SubProp1":"subValue4", "SubProp2":"SubValue5", } ] }I have found that I can manipulate the subArrays by using a JSON splitter and working on each one individually, I have not however found out how to use the join snap to properly put them back into the required space once this is done.
- cjhoward185 years agoEmployee
you can use the match operator to match the each doc in the array and map it to whatever you’d like
so using this expression:
$Subarray.map(entry => match entry { {SubProperty1, SubProperty2} => {"SubProp1": SubProperty1, "SubProp2": SubProperty2}, _ => []})mapped to
MyArrayshould give you the desired output for the nested array portion. The rest seems to just be direct mappings from sourceProperty1to targetProp1,Property2to targetProp2while setting pass through to off.One thing to note, the ‘_’ is used as a default incase there is a document that does not match any of the arms in the match. So, if there is a doc that does not have these fields it would default to an empty array, which you can change.
- MarotReply5 years agoNew Contributor II
Thank you, this solutions seems to work!
- MarotReply5 years agoNew Contributor II
This works, thank you very much!