Since many (most?) web sites are moving from XML data format to JSON I'm wondering if anyone has tried to write a plugin for JSON parsing? Something like WebJSONParser that takes a URL and returns a table with all of the JSON values (or maybe just the requested ones) that a skin could pull from? I've searched through the forums and via Google but all I can find is a suggestion to use WebParser and a LUA JSON parser. That might work, but it is cumbersome and LUA isn't really the right thing to write a parser in performance wise. I don't have any experience writing a plugin, but do have 15+ years of C/C++ experience and there are many C/C++ parser libraries out there to do the actual parsing. I'm assuming I could use the WebParser code for the network stuff, but even that isn't that hard (the curl library will do that and is easy to call).
I'm not afraid of giving it a try, but if someone already wrote one that works or has a start of one I'd rather write skins. Any suggestions on inputs/outputs or best way to call it would also be appreciated.
= Ron
It is currently April 24th, 2024, 11:05 pm
JSON Parser
-
- Posts: 6
- Joined: May 27th, 2016, 6:34 am
-
- Posts: 6
- Joined: May 27th, 2016, 6:34 am
Re: JSON Parser
So 22 views and not a single response . Does that mean no one knows the answer or no one cares about a JSON parser other than myself?
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: JSON Parser
The answer to your original question is probably "no, nobody has written a JSON parser for Rainmeter", at least not that I am aware of.
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: JSON Parser
As to the suggestion, I actually don't care all that much about JSON myself but have no issue with the concept of someone writing a plugin for Rainmeter that could help with parsing it. I would never in a million years re-invent the wheel and create all the connectivity and downloading stuff that WebParser has, just use a WebParser measure that gets an entire JSON output as input to the JSON parser.
Something like:
Or some such.
Returns Smith.
Something like:
Code: Select all
[GetJSON]
Measure=Plugin
Plugin=WebParser
URL=http://somesite.com
RegExp=(?siU)^(.*)$
[GetEmployee2ndLastName]
Measure=Plugin
Plugin=JSON
Source=[GetJSON]
ElementTrail=employees:lastname
ElementCount=2
Code: Select all
{"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]}
-
- Posts: 60
- Joined: July 30th, 2014, 1:00 am
Re: JSON Parser
I would love to see a JSON plugin available. Most of web api return JSON table now.
- Rainmeter 4.3.1.3321 64-bit (Sep 22 2019) - French (1036)
- Windows 10 Pro 1909 64-bit (build 18363) - French (1036)
- Path: D:\Programmes\Customisation\Rainmeter\
- SkinPath: D:\Programmes\Customisation\Rainmeter\Skins\
- SettingsPath: D:\Programmes\Customisation\Rainmeter\
- IniFile: D:\Programmes\Customisation\Rainmeter\Rainmeter.ini
-
- Posts: 6
- Joined: May 27th, 2016, 6:34 am
Re: JSON Parser
Thanks jsmorley, this was the sort of input I was hoping for. You are correct as to re-inventing the wheel. While I have in the past written all of that code to get a web page my plan was to either lift the code from WebParser itself or use the open-source CURL library. But using a WebParser measure hadn't occurred to me. It would allow me to concentrate on the JSON parser code. You'll probably care about JSON at some point as everyone is slowly dropping XML in favor of JSON. Thanks for the suggestions.
= Ron
= Ron