It is currently March 28th, 2024, 6:35 pm

JSON Parsing

Get help with creating, editing & fixing problems with skins
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy
Contact:

Re: JSON Parsing

Post by fonpaolo »

Another interesting argument, is that they allow you to distribute your "App", if you clearly add from where the data are provided.
Nothing more or less than we do with Weather.com. ;-)
takochako
Posts: 9
Joined: September 11th, 2017, 9:19 pm

Re: JSON Parsing

Post by takochako »

FreeRaider wrote:Starting from your first post:

Code: Select all

RegExp=(?siU).*"currently": \{.*"temperature":(.*),.*
Anyway, I agree with jsmorley, because that A with ^ is a unicode problem.
I just tried this and it returns with "RegExp matching error (-1)" in the log.

Here's what the meters and measures look like so far:

Code: Select all

[MeasureWeatherUrl]
Measure=Plugin
Plugin=WebParser
URL=https://api.darksky.net/forecast/(removed)/(removed),(removed),(removed)
RegExp=(?siU).*"currently": {.*"temperature":(.*),.*
UpdateRate=300

[MeasureTemp]
Measure=Plugin
Plugin=WebParser
URL=[MeasureWeatherUrl]
StringIndex=1
UpdateRate=300

[MeterTemp]
Meter=String
MeasureName=MeasureTemp
FontColor=255,255,255,255
FontFace=Ubuntu
FontSize=36
Antialias=1
Text=%1 [\x00B0]
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: JSON Parsing

Post by FreeRaider »

Code: Select all

(?siU).*"currently":.*\{.*"temperature":(.*),.*
Try this one.
It works for me.


P.S.: you have to use the backslash \ before { because this one is a reserved character.
RESERVED CHARACTERS:

There are a few "reserved characters" in Regular Expressions. They are:

[ \ ^ $ . | ? * + ( { }

If you use these characters in a "search" or "endsearch" component, RegExp will assume they are commands, not text, and the expression will fail. To use these characters, you must "escape" them with the "\" (backslash) character. Use "\\" to escape the "\" character itself.
Last edited by FreeRaider on September 12th, 2017, 7:37 pm, edited 1 time in total.
takochako
Posts: 9
Joined: September 11th, 2017, 9:19 pm

Re: JSON Parsing

Post by takochako »

FreeRaider wrote:

Code: Select all

(?siU).*"currently":.*\{.*"temperature":(.*),.*
Try this one.
It works for me.
This one works! Thank you sooooooo much!
jsmorley wrote:One thing you might do is set Debug=2 on the parent WebParser measure and refresh the skin one time. That will give you a file WebParserDump.txt in the skin folder. Then change the URL to

URL=file://#CURRENTPATH#WebParserDump.txt

While you are designing and testing. That way you don't blow through your 1,000 free calls for the day while you are hammering it over and over to tweak the design.

When you are happy, then change the URL back.
Thanks, this is some incredibly helpful information to know when working with these sorts of things, I've got to have gone through like 600 yesterday and this morning. xD

Now the only problem that I know about is when refreshing it, I can see the degree sign, but the it disappears and is replaced with a 6. It's trying to say 67 degrees but even with changing the width it won't show the whole thing.
fabyouless
Posts: 1
Joined: September 29th, 2017, 11:06 pm

Re: JSON Parsing

Post by fabyouless »

Interrogative: Is it necessary to have the .* at the beginning and ending of the regex? Or, will this code also work?

Code: Select all

(?siU)"currently":.*"temperature":(.*),
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: JSON Parsing

Post by balala »

fabyouless wrote:Interrogative: Is it necessary to have the .* at the beginning and ending of the regex? Or, will this code also work?

Code: Select all

(?siU)"currently":.*"temperature":(.*),
Have you tried your RegExp? If yes, does it work? It's easy to investigate yourself...
Post Reply