My data provider sends me data in 2 different structures.Difference in imageValue field
- object in about group
- array in banner group
{"valuesToUpload": [ {"groupId": "about_2","groupTitle": "","fields": [ {"fieldType": "image","valueId": "cd262467-e683-4b1a-8fff-b22c42722f2c","toUpload": true,"imageValue": {"imageId": 27606887612,"imageSchema": "profile_composition","url": "http://img10/image/1/1.YaE0cFYle0oRLlTPlS7HAwtEINoMkYFRuB_k" } }, {"fieldType": "image","fieldName": "example_images","valueId": "5b394732-28c1-424c-a5c8-5edd553a3711","toUpload": true,"imageValue": {"imageId": 27606306642,"imageSchema": "profile_composition","url": "http://img40/image/1/1.j_RTsLassXjnkzZKMn-0czdeML_SxCdo-c" } }, {"fieldType": "image","fieldName": "example_images","valueId": "efaeca0d-9dbe-4b1c-93a1-51cb54b9ec1b","toUpload": true,"imageValue": {"imageId": 27606343705,"imageSchema": "profile_composition","url": "http://img00/image/1/1.xNLAhbas-l50pn65eZTqgqHrazl2.r39lMZMqeTovl4Cj2EY" } }] }, {"groupId": "banner","groupTitle": "banner","fields": [ {"fieldType": "image","imageValue": [ {"imageId": 0000001,"toUpload": true,"valueId": "efaeca0d-9dbe-4b1c-93a1-51cb54b9ec00","imageSchema": "profile_composition","url": "https://20.img.st/image/1/link1" }, {"imageId": 0000002,"toUpload": false,"valueId": "efaeca0d-9dbe-4b1c-93a1-51cb54b9ec01","imageSchema": "profile_composition","url": "https://20.img.st/image/1/link2" } ],"fieldName": "banner","fieldTitle": "banner" } ] } ],"reload": {"on": false }}
I need to "recompile" banner group image fields to format same as in about_2 group
I found out how to select only separate object format (about_2):
{"valuesToUpload":[ .payload.valuesToUpload[]|{groupId,groupTitle,fields:[.fields[]| select(.valueId != null)]}]}
And get only "about_2" section.
But how to write jQuery to recompile banner section to same format and not lost about_2 section.
Banner section must be like:
{"groupId": "banner","groupTitle": "banner","fields": [ {"fieldType": "image","valueId": "efaeca0d-9dbe-4b1c-93a1-51cb54b9ec00","toUpload": true,"imageValue": {"imageId": 0000001,"imageSchema": "profile_composition","url": "https://20.img.st/image/1/link1" } }, {"fieldType": "image","valueId": "efaeca0d-9dbe-4b1c-93a1-51cb54b9ec01","toUpload": true,"imageValue": {"imageId": 0000002,"imageSchema": "profile_composition","url": "https://20.img.st/image/1/link2" } } ]}