0

I need to import some JSON data am getting into my database. I'd like to use PowerShell and figured out a little, but I need help getting the final piece together. How to convert following nested JSON to flat CSV in Powershell? Following is the JSON data :

$openings = '{"objects": [ { "id": 136691, "title": "UX Desginer",
"description": "Hiring a UX Designer for our Front End Team", "position_type": "full_time", "is_remote_allowed": false, "is_archived": false, "is_private": false, "state": "Draft", "location": { "city": "Bangalore", "state": "Karnataka", "zipcode": "560078", "country": "India" }, "team": "Front-end Team", "created_date": 1472804002, "modified_date": 1472804018, "application_email": "recruiterbox-dmcc0616@applications.recruiterbox.com", "hosted_url": "https://recruiterbox.recruiterbox.com/jobs/d933h5yh" }, { "id": 136691, "title": "UX Desginer",
"description": "Hiring a UX Designer for our Front End Team", "position_type": "full_time", "is_remote_allowed": false, "is_archived": false, "is_private": false, "state": "Draft", "location": { "city": "Bangalore", "state": "Karnataka", "zipcode": "560078", "country": "India" }, "team": "Front-end Team", "created_date": 1472804002, "modified_date": 1472804018, "application_email": "recruiterbox-dmcc0616@applications.recruiterbox.com", "hosted_url": "https://recruiterbox.recruiterbox.com/jobs/d933h5yh" } ], "meta": { "total": 1, "limit": 20, "offset": 0 }}'

  • Please [format your code and sample input/output properly](http://meta.stackexchange.com/a/22189/248777). – mklement0 Feb 28 '19 at 13:50
  • Please read about [how to ask a good question](http://stackoverflow.com/help/how-to-ask). – mklement0 Feb 28 '19 at 13:50
  • You should include an example what output you want. There is no straight forward way to convert a nested format (json) to flat (csv). – marsze Feb 28 '19 at 14:50
  • `$x.meta | ConvertTo-Csv -NoTypeInformation` and `$x.objects | ConvertTo-Csv -NoTypeInformation` providing that `$x = $openings | ConvertFrom-Json`. Diving into `$x.objects` you can see a property `state` used as `$x.objects.location.state` and `$x.objects.state`. Their different meaning (_country_ vs. _status_) does not matter unlike their identical name if you would expand the property `$x.objects.location`. – JosefZ Feb 28 '19 at 16:41
  • Possible duplicate of [Convert nested JSON array into separate columns in CSV file](https://stackoverflow.com/questions/45829754/convert-nested-json-array-into-separate-columns-in-csv-file) – iRon Feb 28 '19 at 17:56

0 Answers0