Page 1 of 1

Parse JSON

Posted: Sat Mar 24, 2018 3:55 pm
by bdemarchi
Hi All,

Just sharing a plugin that allows you to work with JSON on Calc.

I could not find a way to do that with OpenOffice 4.1.1.

This plugin allows you to specify a JSON url (API provided by many sites) and query through it using a query format similar to XPath.
It adds a function to Calc named PARSEJSON(url, query).
Read the Readme.txt if you wants to undestand how to use it.

https://github.com/bdemarchi/parseJSON

Regards

Edit:
As pointed out there is another extension that works with JSON.
I went to https://extensions.openoffice.org but could not find that extension there and that is why I decided to implement something.
Also, there is LibreOffice and there is OpenOffice, two different products. I am using OpenOffice, I don't see any reason to go look at LibreOffice extensions and try to use them on OpenOffice. I haven't seen anything while using OpenOffice that clearly states we can use LibreOffice plugins.
I still have to add this extension to the OpenOffice extension site, will update this post once that is done.

Re: Parse JSON

Posted: Sat Mar 24, 2018 4:40 pm
by Villeroy

Re: Parse JSON

Posted: Sun Mar 25, 2018 12:51 pm
by Villeroy
IMHO, the "getrest" extension is more efficient because it allows you to download the data with one GET formula and then analyse the downloaded string by means of dozends of function calls to =com.github.binnarywolf.LibreOfficeGetRestPlugin.parseJSON().

Your function =com.github.fbdm.parseJSON.parseJSON() triggers one download with every function call. It can not parse the content of a cell.

Both add-ins return numeric strings which is pointless in a arithmetic software.
LibreOffice has a NUMBERVALUE function which allows you to specify the decimal separator: =NUMBERSTRING(A1;".")
The workaround for OpenOffice reads the second char of a known decimal fraction and replaces it within the given string with the actually wanted decimal before converting the string to value: =VALUE(SUBSTITUTE("138.98" ; "." ; MID(PI() ; 2 ; 1))). In case of a comma locale, the point in 138.98 will be replaced with the comma borrowed by the PI() function. Instead of PI() you could also use any other fraction like 1/2

Oh, and the locale for Brazilian language is pt-BR. Language=pt, country=BR