How to convert JSON to CSV or create records

Jay75
Tera Contributor

Hello experts,

I am working on converting JSON response to create a CSV file, so i can create a data source record sys_data_source.

Please could you help me in either JSON response to converting csv attachment or directly inserting it my staging table.

Background: I have the staging table created with all columns from json response. I used online sites to convert the attached JSON to csv and uploaded in Staging table. But I want scheduled job or script to do this conversion to csv or insert of records directly in to staging table.

 

Please see the attached JSON response. I am new with JSON and integrations. so any advise or code will be very helpful.

 

Regards,

Newbie

4 REPLIES 4

SanjivMeher
Kilo Patron
Kilo Patron

You can definitely use CSV. But if you already have JSON, you can pass the JSON as content or attach the JSON file to the data source and then set the format in the data source as JSON and run import to import the JSON.

ds.format = "JSON";


Please mark this response as correct or helpful if it assisted you with your question.

Thank you Sanjiv for the response. I was not aware of the JSON file datasource. 
What should i put value for "Path for each row"

 

So depends on your payload.

If your JSON array doesnt starts from the begining, you can use 

ds.jpath_root_node = "//";

If it is inside a JSON, you can specify the path, for ex

ds.jpath_root_node = "/results/results";


Please mark this response as correct or helpful if it assisted you with your question.

Jay75
Tera Contributor

I am getting error when i load the data (source of import = Data source).

I am interested in all child objects of "Products".