It is currently September 21st, 2020, 8:02 pm

Json Parser Plugin

Share and get help with Plugins and Addons
nek
Posts: 29
Joined: November 3rd, 2019, 12:00 am

Re: Json Parser Plugin

Post by nek »

hi.
JelleDekkers wrote: February 1st, 2020, 2:11 pm but this just crashes Rainmeter:
Same with me.

Code: Select all

Rainmeter 4.4.0.3338 beta (64-bit)
Language: English (1033)
Build time: 2019-11-19  7:55:40
Commit Hash: ab72019a
Windows 10 Pro 1909 64-bit (build 18363) - Japanese (1041)
I have tested some Query= strings.
Here are the results.

Code: Select all

[Rainmeter]
Update=-1
DefaultUpdateDivider=-1

[MeasureJSONParser]
Measure=Plugin
Plugin=JsonParser
Source={"a b":"c d"}

;;Rainmeter.exe crashed.
;Query="a b"
;Query="$.a b"
;Query=["a b"]
;Query='["a b"]'
;Query="[a b]"
;Query='a b'
;Query=a b

;;It works.
;Query=['a b']
Query="['a b']"

[MeterString]
Meter=String
W=100
H=40
SolidColor=FFFFFFFF
We can see the measure current value at
Rainmeter icon > About dialog > Skins tab
User avatar
e2e8
Posts: 8
Joined: January 5th, 2020, 8:18 am

Re: Json Parser Plugin

Post by e2e8 »

nek wrote: February 1st, 2020, 6:15 pm

Yeah looks like you have to use bracket notation for properties with spaces. This JSON library also seems to require single quotes and not double quotes inside the brackets around the property name even though that is not according to the JSON spec.

Code: Select all

{
 "a":   
  {
   "b c":"d" 
  }
}

a['b c']
I will fix the crashing so it shows an error instead
User avatar
JelleDekkers
Posts: 58
Joined: September 27th, 2017, 6:32 pm

Re: Json Parser Plugin

Post by JelleDekkers »

Thanks, that did the trick. Would it also be possible to get the raw value of something? I'm trying to parse something like "2020-02-01T08:23:05+0100", but the plugin changes that to the Windows short date and long time format ("1-2-2020 08:23:05" in my case). I don't want it to do that :P
Henk1956
Posts: 6
Joined: January 17th, 2020, 10:59 pm

Re: Json Parser Plugin

Post by Henk1956 »

Noticed something similar. I am parsing a number (like 3.14). When doing so, the number value is 3.14 but the sting value is 3,14. This caused problems because I used the SetVariable bang to assign its value to a variable. But this bang assigns the string value and not the number value. Hence calculations using this variable failed. Found out that this is due to my OS settings. In Dutch, the decimal point (.) and thousands separator (,) as used in English notation, are used in the opposite way (we use (,) as decimal point and (.) as thousands separator). By changing my OS settings to use the English notation, the string value of 3,14 changes into 3.14 which solved my problem.
So, it seems that the plugin translates anything in a recognisable format to a string, according to your OS settings.
Would be nice if the plugin did not do that (since rainmeter doesn't do that either, you don't expect that to happen).

Otherwise, a great plugin!!!
User avatar
e2e8
Posts: 8
Joined: January 5th, 2020, 8:18 am

Re: Json Parser Plugin

Post by e2e8 »

New Release of Json Parser Plugin. Preview of 1.1 https://github.com/e2e8/rainmeter-jsonparser/releases/tag/1.1

Consider this a preview release for the moment. I hope to test more and release final soon. Try it out if you would like and report any issues here or on github.

Most of the new features should documented here: https://github.com/e2e8/rainmeter-jsonparser/tree/1.1

Added Logging options
Added Locale option
Added Section Variable Functions for Query and Length
Removed automatic translation of Dates/Times into Windows format. (I hope to re-add date string formatting as an option)
Fixed crash on space in property name.

Breaking Change: I moved the reading of options to the Reload function as recommended in the guidelines from Rainmeter. This meant that I needed to in my own skin to add DynamicVariables=1 to my Measures

I hope I have addressed all the feedback so far in this thread. Let me know if not.
User avatar
JelleDekkers
Posts: 58
Joined: September 27th, 2017, 6:32 pm

Re: Json Parser Plugin

Post by JelleDekkers »

e2e8 wrote: February 10th, 2020, 8:56 am New Release of Json Parser Plugin. Preview of 1.1 https://github.com/e2e8/rainmeter-jsonparser/releases/tag/1.1

Consider this a preview release for the moment. I hope to test more and release final soon. Try it out if you would like and report any issues here or on github.

Most of the new features should documented here: https://github.com/e2e8/rainmeter-jsonparser/tree/1.1

Added Logging options
Added Locale option
Added Section Variable Functions for Query and Length
Removed automatic translation of Dates/Times into Windows format. (I hope to re-add date string formatting as an option)
Fixed crash on space in property name.

Breaking Change: I moved the reading of options to the Reload function as recommended in the guidelines from Rainmeter. This meant that I needed to in my own skin to add DynamicVariables=1 to my Measures

I hope I have addressed all the feedback so far in this thread. Let me know if not.
Removing the date translation is a good change imo, but it doesn't cover all of the conversions the plugin does. I really do suggest removing all conversions done to values, so it's more similar to WebParser. One thing I noticed as well is that the plugin makes Rainmeter crash when a captured value is null.
nek
Posts: 29
Joined: November 3rd, 2019, 12:00 am

Re: Json Parser Plugin

Post by nek »

Hi, e2e8
Thank you for the update. I am testing new JsonParser 1.1 pre.
e2e8 wrote: February 10th, 2020, 8:56 am New Release of Json Parser Plugin. Preview of 1.1
raiguard wrote: January 17th, 2020, 6:26 pm That would be okay, though I would do it like Logging=0. That way you could add other logging modes (2,3,4,...) in the future if you wished.
As raiguard said, how about like this ?
20200211.png
- Basically, I would like to reduce Skin file size as possible.
Logging(7 char), Debug(5 char), Log(3 char)

- While Skin is loading, these error logged by each [Measure].
Error reading JToken from JsonReader. Path '', line 0, position 0. (...Skin.ini - [msLC_clat])
Rainmeter > About Dialog > Log

The measure is set Disabled=1, but error occurerd.

Code: Select all

[msLC_clat]
Measure=Plugin
Plugin=JsonParser
Query="latitude"
Source=[msWebParser]
Disabled=1
Group=grResults
- There are a lot of [Measure], so I need to add Logging=NoMatch:0,EmptySource:0 every JSONParser Measures.
I preffer "Logging/Debug is off by default".

P.S. I am not a programmer, and English is not my language,
If you feel uncomfortable, you can ignore this replay.
You do not have the required permissions to view the files attached to this post.
Last edited by nek on February 11th, 2020, 10:37 pm, edited 1 time in total.
nek
Posts: 29
Joined: November 3rd, 2019, 12:00 am

Re: Json Parser Plugin

Post by nek »

There are differences between JsonParser.dll 1.0 and 1.1 pre,
when the Measure is set Disabled=1 in the same skin.

Code: Select all

[Rainmeter]
Update=-1
DefaultUpdateDivider=-1
;;;;Debug begin
OnUpdateAction=[!Log "#CURRENTSECTION# | Update" Debug]
;;;;Debug end

[MeasureJSONParser]
Measure=Plugin
Plugin=JsonParser
Query="a"
Source={"a":"b"}
Disabled=1
;DynamicVariable=1
;;;;Debug begin
OnUpdateAction=[!Log "#CURRENTSECTION# | Update" Debug]
;;;;Debug end

[MeterString]
Meter=String
W=100
H=40
SolidColor=FF00FFFF
;;;;Debug begin
OnUpdateAction=[!Log "#CURRENTSECTION# | Update" Debug]
;;;;Debug end
JsonParser.dll 1.0
jspr10.png

Code: Select all

NOTE (00:55:13.982) JSONParser.test\Skin.ini: Refreshing skin
DBUG (00:55:13.984) JSONParser.test\Skin.ini: Reading file: Z:\Apps\Rainmeter\Skins\JSONParser.test\Skin.ini
DBUG (00:55:13.986) : Reading file: Z:\Apps\Rainmeter\Rainmeter.ini
DBUG (00:55:13.987) JSONParser.test\Skin.ini: MeterString | Update
DBUG (00:55:13.988) JSONParser.test\Skin.ini: Rainmeter | Update
JsonParser.dll 1.1 pre.
jspr11.png

Code: Select all

NOTE (00:52:15.249) JSONParser.test\Skin.ini: Refreshing skin
DBUG (00:52:15.250) JSONParser.test\Skin.ini: Reading file: Z:\Apps\Rainmeter\Skins\JSONParser.test\Skin.ini
DBUG (00:52:15.252) : Reading file: Z:\Apps\Rainmeter\Rainmeter.ini
DBUG (00:52:15.253) JSONParser.test\Skin.ini - [MeasureJSONParser]: Log Config: 
DBUG (00:52:15.254) JSONParser.test\Skin.ini - [MeasureJSONParser]: Log Config: Log NoMatch: True
DBUG (00:52:15.254) JSONParser.test\Skin.ini - [MeasureJSONParser]: Log Config: Log EmptySource: True
DBUG (00:52:15.255) JSONParser.test\Skin.ini - [MeasureJSONParser]: Locale Config: 
DBUG (00:52:15.256) JSONParser.test\Skin.ini - [MeasureJSONParser]: Source: {"a":"b"}
DBUG (00:52:15.256) JSONParser.test\Skin.ini - [MeasureJSONParser]: Query: a
DBUG (00:52:15.257) JSONParser.test\Skin.ini - [MeasureJSONParser]: Result: b
DBUG (00:52:15.257) JSONParser.test\Skin.ini: MeterString | Update
DBUG (00:52:15.259) JSONParser.test\Skin.ini: Rainmeter | Update
My Environment, Rainmeter portable mode is installed.

Code: Select all

Rainmeter 4.4.0.3338 beta (64-bit)
Language: English (1033)
Build time: 2019-11-19  7:55:40
Commit Hash: ab72019a
Windows 10 Pro 1909 64-bit (build 18363) - Japanese (1041)
Path: Z:\Apps\Rainmeter\
SkinPath: Z:\Apps\Rainmeter\Skins\
SettingsPath: Z:\Apps\Rainmeter\
IniFile: Z:\Apps\Rainmeter\Rainmeter.ini
You do not have the required permissions to view the files attached to this post.
User avatar
JelleDekkers
Posts: 58
Joined: September 27th, 2017, 6:32 pm

Re: Json Parser Plugin

Post by JelleDekkers »

Is there any way to get multiple tokens? Right now it just errors out saying it gets multiple tokens. What I'd like to see is an output like this: Token0, Token1, etc.
Falxon
Posts: 12
Joined: May 5th, 2020, 3:04 pm

Re: Json Parser Plugin

Post by Falxon »

I just wanted to say thanks!

Your plugin allowed me to redo all of my weather skins and as a result, I was inspired to write my own plugin to convert Unix timestamps into human-readable format. This way, there is no need to rely on messy scripting in skins. I just posted the announcement on a thread in this forum.

I'd love to hear your feedback on it given your experience!

https://forum.rainmeter.net/viewtopic.php?f=128&t=35200