Re: Json Parser Plugin
Posted: June 6th, 2020, 7:49 am
This is so cool. Thanks!!!
There are several problems with your approach:ElMalditoBatman wrote: ↑April 4th, 2023, 3:13 pm Hi Sorry to dig up such an old thread, but hoping someone might be able to assist on this error.
I am trying to pull the name field after filtering for a specific server name in a json file. json file data seems to be downloading just fine. plugin seems to load no issues. But I am getting a "Error reading JToken from JsonReader. Path '', line 0, position 0." error on the logs whenever I try to query up for the information I need.
Code: Select all
[Rainmeter]
Update=10000
AccurateText=1
DynamicWindowSize=1
--- First test sample from https://www.newtonsoft.com/json/help/html/SelectToken.htm with new lines removed ---
; [MeasureTest]
; Measure=String
; String="{ 'Stores': [ 'Lambton Quay', 'Willis Street' ], 'Manufacturers': [ { 'Name': 'Acme Co', 'Products': [ { 'Name': 'Anvil', 'Price': 50 } ] }, { 'Name': 'Contoso', 'Products': [ { 'Name': 'Elbow Grease', 'Price': 99.95 }, { 'Name': 'Headlight Fluid', 'Price': 4 } ] } ]}"
; [MeasureManufacturerName]
; Measure=Plugin
; Plugin=JsonParser.dll
; Source=[MeasureTest]
; Query="Manufacturers[0].Name"
; DynamicVariables=1
--- Actual sample from http://arkdedicated.com/xbox/cache/unofficialserverlist.json ---
; REFERENCES:
; - SourcePage: http://arkdedicated.com/xbox/cache/unofficialserverlist.json
; - Formatting: https://webformatter.com/
; - Query Info: https://www.newtonsoft.com/json/help/html/SelectToken.htm
[MeasureArkServerList]
Measure=WebParser
URL=http://arkdedicated.com/xbox/cache/unofficialserverlist.json
RegExp=(?siU)^(.*?)$
[MeasureNumPlayers]
Measure=Plugin
Plugin=JsonParser.dll
Source=[MeasureArkServerList]
Query="$[?(@.Name == '[US] Back Seat Gaming Official')].MapName"
DynamicVariables=1
--- Meters ---
[MapGenesisLabel]
Meter=String
X=5
Y=3R
W=300
H=15
FontSize=11
FontColor=255,225,181,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Genesis 1:
[MeterGenesisPlayers]
Meter=String
MeasureName=MeasureNumPlayers
X=315
Y=0r
W=300
H=15
FontSize=11
FontColor=252,251,202,255
SolidColor=0,0,0,1
Padding=5,5,5,5
StringAlign=Right
AntiAlias=1
You're welcome - glad to help. Thanks for the appreciation, others here are too!ElMalditoBatman wrote: ↑April 4th, 2023, 7:12 pm Dude you are amazing!. Thank you! And yes, I figured it had something to do with the huge json file. This is my first time working with rainmeter, and I appreciate all the notes. I was having trouble finding others with a similar matter to learn off of.
Code: Select all
Error reading JToken from JsonReader. Path '', line 0, position 0. (ashuramaru\panel\panel.ini - [Measure_Version_Parse])
Error reading JToken from JsonReader. Path '', line 0, position 0. (ashuramaru\panel\panel.ini - [Measure_Version_Parse])
Code: Select all
{
"Ashuramaru_Bundle": [
{
"version": "1.1.1"
}
]
}
Code: Select all
[Measure_Version]
Measure=Webparser
Url=https://raw.githubusercontent.com/Kurou-kun/Ashuramaru-Bundle/main/version.json
RegExp=(?siU)^(.*?)$
OnConnectErrorAction=[!Log "Couldn't connect to the destination!"]
OnRegExpErrorAction=[!Log "RegExp Exception!"]
[Measure_Version_Parse]
Measure=Plugin
Plugin=JsonParser
Source=[Measure_Version]
Query="Ashuramaru_Bundle[0].version"
UpdateRate=500
DynamicVariables=1
OnUpdateAction=[!CommandMeasure "Script_Panel" "upgrade('[Measure_Version_Parse]')"] <-- This function just toggles meters basing on the provided value
I don't know what could be the problem, since it doesn't seem like an misformatted query or anything like it (i.e. even commenting out the query altogether doesn't get rid of the error). Might be one of those initial errors at skin parsing / loading time, when everything is empty and you have side effects until the data is retrieved, considering we talk about a WebParser measure as a source. The curious thing is that starting with the plugin measure initially disabled should solve it, but for some reason, it doesn't.
Code: Select all
[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
---Measures---
[Measure_Version]
Measure=WebParser
Url=https://raw.githubusercontent.com/Kurou-kun/Ashuramaru-Bundle/main/version.json
RegExp=(?s)^(.*)$
UpdateRate=500
OnConnectErrorAction=[!Log "Couldn't connect to the destination!"]
OnRegExpErrorAction=[!Log "RegExp Exception!"]
FinishAction=[!EnableMeasure Measure_Version_Parse][!UpdateMeasure Measure_Version_Parse][!UpdateMeter SomeMeter][!Redraw]
DynamicVariables=1
[Measure_Version_Parse]
Disabled=1
Measure=Plugin
Plugin=JsonParser.dll
Source=[Measure_Version]
Query="Ashuramaru_Bundle[0].version"
UpdateDivider=-1
OnUpdateAction=[!Log "Updated"]
DynamicVariables=1
---Meters---
[SomeMeter]
Meter=String
SolidColor=0,0,0,1
FontColor=100,255,100,255
FontFace=Consolas
FontSize=16
AntiAlias=1
MeasureName=Measure_Version_Parse
Text=Version: %1
UpdateDivider=-1
LeftMouseUpAction=[!EnableMeasure Measure_Version_Parse][!UpdateMeasure Measure_Version_Parse][!UpdateMeter SomeMeter][!Redraw]
DynamicVariables=1
Got itYincognito wrote: ↑May 25th, 2023, 4:59 pm I don't know what could be the problem, since it doesn't seem like an misformatted query or anything like it (i.e. even commenting out the query altogether doesn't get rid of the error). Might be one of those initial errors at skin parsing / loading time, when everything is empty and you have side effects until the data is retrieved, considering we talk about a WebParser measure as a source. The curious thing is that starting with the plugin measure initially disabled should solve it, but for some reason, it doesn't.