I've got a API JSON service and need to create a script to export data to CSV files.
Does anyone have a php script to migrate JSON to CSV format?
Example Json file
{"packWidth":200,
"itemNo":"SEH404",
"groupItemNo":"SEH404",
"status":1,
"categoryId":24356,
"packType":"ColorBox",
"barcode":"1234567890987",
"modelLabel":"Color",
"modelList":[{"key":"SEH404","value":"Black"},{"key":"SEH404W","value":"White"}],
"packQty":20,
"packInclude":"USB Adapter, USB Charger, Earphone, Leather Case",
"id":3456}
An important part is the array with the tag "modelList"
The result of the array modelList, must be a column for each value
example:
packWidth, itemNo, groupItemNo, status, categoryId, packType, barcode, modelLabel, modelList1, modelList2, packQty, packInclude, id
200, SEH404, SEH404, 1, 24356, ColorBox, 1234567890987, Color, SEH404:Black, SEH404W:White, 20, USB Adapter... , 3456
Some products may also contain 5 records "modelList1-modelList2 modelList3-modelList4-modelList5. Products without modelList will record modelList empty.
See Question&Answers more detail:
os