DmytroBazunov / LibreOfficeGetRestPlugin

The extension for LibreOffice Calc that's allows LibreOffice to get data from rest server.
38 stars 12 forks source link

Unable to parse structues with a period #9

Open BewilderedAgain opened 6 years ago

BewilderedAgain commented 6 years ago

The JSON date structure I need to parse is ( in cell A34):

{ "Meta Data": {
"1. Information": "Batch Stock Market Quotes",
"2. Notes": "IEX Real-Time",
"3. Time Zone": "US/Eastern"
},
"Stock Quotes": [
{
"1. symbol": "MSFT",
"2. price": "108.0000",
"3. volume": "--",
"4. timestamp": "2018-08-03 15:59:57"
},
{
"1. symbol": "FB",
"2. price": "177.7600",
"3. volume": "--",
"4. timestamp": "2018-08-03 15:59:59"
},
{
"1. symbol": "AAPL",
"2. price": "207.9600",
"3. volume": "--",
"4. timestamp": "2018-08-03 15:59:55"
}
] }

If I try to parse to get the price of MSFT using PARSEJSON(A34;"Stock Quotes.get(0).2. price")

I get "No such node found". It would seem the use of period as a delimiter is problematic. I could workaround by editing the returned stucture but i wonder if there might be a better way.

BewilderedAgain commented 6 years ago

Further, I see I could edit the the line in the parser

final String[] commands = aParsePattern.trim().split("\.");

to split using an unlikely string say "~#" but converting that into an OXT is beyond my knowledge.

tinducvo commented 3 years ago

Ha, I have the same problem. I'm probably just going to use a different data source. Great work by the writer though

tinducvo commented 3 years ago

The JSON date structure I need to parse is ( in cell A34):

{ "Meta Data":

{ "1. Information": "Batch Stock Market Quotes", "2. Notes": "IEX Real-Time", "3. Time Zone": "US/Eastern" }, "Stock Quotes": [ { "1. symbol": "MSFT", "2. price": "108.0000", "3. volume": "--", "4. timestamp": "2018-08-03 15:59:57" }, { "1. symbol": "FB", "2. price": "177.7600", "3. volume": "--", "4. timestamp": "2018-08-03 15:59:59" }, { "1. symbol": "AAPL", "2. price": "207.9600", "3. volume": "--", "4. timestamp": "2018-08-03 15:59:55" } ] }

If I try to parse to get the price of MSFT using PARSEJSON(A34;"Stock Quotes.get(0).2. price")

I get "No such node found". It would seem the use of period as a delimiter is problematic. I could workaround by editing the returned stucture but i wonder if there might be a better way.

Here is my fix lol: REGEX(cellRef, " *", "")