I have JSON data structured as follows (there might be some errors here, the data I use is fine):
[{ "id": 12345, "itemName": "some string", "sellerId": 123, "seller": "", "categoryId": , "categoryPath": [ { //more data }, { //more data } ]}, {"id": 12346, "itemName": "some other string", "sellerId": 234, "seller": "", "categoryId": , "categoryPath": [ {
I would like to convert it to csv so that the selected property names become csv headers and their value (only depth 1) becomes data. eg
id,itemName,sellerId 12345,"some string",123 12346,"some other string",234
I tried using hundreds of options
cat file.json | convertfrom-json | convertto-csv
but no one worked. All I get is csv data with names / types of objects, and I cannot figure out how to make it use only the selected properties of each object from json data.
source share