How to parse JSON files

I would like to be able to parse JSON files into Libre Calc. I’m attempting to read a file from a vehicle tuner and want to populate a spreadsheet with the data. Then be able to do editing to the data and then save it back to JSON file. I know Microsoft Excel does this but I’m not a Microsoft owner. Is it possible to do this in Calc?

3 Likes

This is not based on a server. The JSON file is exported from a vehicle tuner as a file.

All I want to do is read the JSON file populate a spreadsheet and then after editing to save the data back to the JSON file again. I’m not sure how python is going to populate a Calc spreadsheet being it’s not on a server but a simple 559 byte file you export from a mobile device.

{“profileName”:“Economy Beta”,“vehicleName”:“V2 Dodge 1998-2002”,“settingsMap”:{“125”:“103”,“133”:“134”,“128”:“113”,“127”:“109”,“139”:“20”,“111”:“15”,“19”:“0”,“116”:“83”,“17”: “1.5”,“118”:“86”,“112”:“15”,“22”:“40”,“131”:“125”,“61”:“3”,“115”:“82”,“62”:“30”,“129”:“117”,“126”: “106”,“114”:“81”,“136”:“149”,“121”:“92”,“140”:“23”,“130”:“121”,“119”:“88”,“104”:“3200”,“85”: “1200”,“60”:“50”,“138”:“18”,“113”:“80”,“124”:“100”,“122”:“94”,“135”:“144”,“132”:“129”,“59”: “5”,“15”:“8”,“134”:“139”,“110”:“0”,“120”:“90”,“137”:“15”,“123”:“97”,“18”:“100”,“141”:“27”,“117”:“84”}}

There are plenty of JSON to CSV converters and vice versa on the net, for example https://json-csv.com/ or JSON To CSV Converter and reverse with https://json-csv.com/reverse or CSV To JSON Converter

If you need something more sophisticated and/or control of the conversion then take a look at the jq tool (jq) and/or csvkit (GitHub - wireservice/csvkit: A suite of utilities for converting to and working with CSV, the king of tabular file formats.), both are usually available as package in your favourite Linux distribution, but also available for WIndows. You’ll need command line knowledge though but both have a decent documentation and you’ll find lots of questions, answers and solutions for example on the stackoverflow site.

1 Like

Actually I’m try to keep it stupid proof. I’m trying to build a spreadsheet to take tuner information allow the end user to see all the number and make his/her edits and write back to JSON file so they can import back to the tuner. I need to keep it down to loading a file and saving a file. Skip the python and other stuff because this has to work for both Windows and Linux people both without a lot of programming.

Just need to parse that JSON clip in a spreadsheet and be able to save back. Without python and conversion scripts.

Hello,

Please see my answer in this post → Importing CSV and manipulating data with macro.

Not certain of part 2 of the question using any plugin - save back to JSON. Python macro certainly can be done for this.

This is not based on a server. The JSON file is exported from a vehicle tuner as a file.

All I want to do is read the JSON file populate a spreadsheet and then after editing to save the data back to the JSON file again. I’m not sure how python is going to populate a Calc spreadsheet being it’s not on a server but a simple 559 byte file you export from a mobile device.

{“profileName”:“Economy Beta”,“vehicleName”:“V2 Dodge 1998-2002”,“settingsMap”:{“125”:“103”,“133”:“134”,“128”:“113”,“127”:“109”,“139”:“20”,“111”:“15”,“19”:“0”,“116”:“83”,“17”:
“1.5”,“118”:“86”,“112”:“15”,“22”:“40”,“131”:“125”,“61”:“3”,“115”:“82”,“62”:“30”,“129”:“117”,“126”:
“106”,“114”:“81”,“136”:“149”,“121”:“92”,“140”:“23”,“130”:“121”,“119”:“88”,“104”:“3200”,“85”:
“1200”,“60”:“50”,“138”:“18”,“113”:“80”,“124”:“100”,“122”:“94”,“135”:“144”,“132”:“129”,“59”:
“5”,“15”:“8”,“134”:“139”,“110”:“0”,“120”:“90”,“137”:“15”,“123”:“97”,“18”:“100”,“141”:“27”,“117”:“84”}}

Appears comment formatting is off here. (Twas the JSON line)

Linked samples do show access to servers. However, Python is not restricted to that. You write code specific to your needs. I have read and written data using Calc and Python many times.

There are requests in Bugzilla for JSON and Calc but none I can see as implemented.

Beyond me. I was just looking for a way to load JSON file in Calc and edit and export back out. I’ve got no clue about python or writing code that way.

1 Like