It is currently March 28th, 2024, 11:40 pm

⭐ Weather.com - Parsing the V3 JSON

Our most popular Tips and Tricks from the Rainmeter Team and others
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by jsmorley »

You are right! I'll change that the next time I modify the @Include files. Thanks!
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by Yincognito »

nek wrote: January 30th, 2021, 7:29 pm I found something, tiny things about regular expressions in the
WeatherComJSON_August 4, 2020.rmskin > WeatherComJSONMeasures.inc | Updated July 31, 2020

There is a code RegExp=(?siU)^(.*)$ for WebParser measure, but RegExp=(?s)^(.*)$ is fewer steps and faster to parse.
You'll find a lot of such things in any skin that uses regex though, not just here. While you're absolutely right that it takes more steps (I'm also careful in that regard, never using something if it's not functionally required), my feeling is that the (?siU) flags are used just as a way to "set and forget" in most skins, where this form is preferred "just in case", even though some of the individual flags are not always needed.

Just curious, why didn't you suggested ^([\s\S]*)$ instead? In your table it's the most efficient, and this is supported by various analyses by regex experts online, who point out that specifying the pattern as close as possible yields the best results in terms of speed. Some even suggest avoiding the . (dot, every character) pattern as often and whenever possible, and "narrow down" the pattern to make it faster.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
nek
Posts: 105
Joined: November 3rd, 2019, 12:00 am

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by nek »

Yincognito wrote: January 30th, 2021, 9:03 pm Just curious, why didn't you suggested ^([\s\S]*)$ instead?
Because...
(?s)^.*$ is cool :thumbup: , and ^([\s\S]*)$ is not.
There are not any technical reasons at all.
I am not expert of the regular expressions, and I don't remember whitch \s \S is match with whitespace character.
I just feel that (?s)^.*$ is more easier to understand for people. That's it.
Last edited by nek on March 23rd, 2021, 6:45 pm, edited 1 time in total.
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by Yincognito »

nek wrote: January 30th, 2021, 10:09 pm Because...
(?s)^.*$ is cool :thumbup: , and ^([\s\S]*)$ is not.
There are not any technical reasons at all.
I am not expert of the regular expressions, and I don't remember whitch \s \S is match with whitespace character.
I just feel that (?s)^.*$ is easy to understand for everyone. That it.
Ah, ok, no problem - I'm not an expert either. I guess I was just confused as to why a technical reason was appropriate for a certain choice, while it wasn't for the other, that's all. :confused:

P.S. Remembering what \s and \S stand for is easy: in regex, lower-case are affirmations, while upper-case are negations (e.g. \d = digit, \D = not digit; \s = whitespace. \S = not whitespace; \w = word, \W= not word; etc).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Rucha
Posts: 13
Joined: August 7th, 2021, 1:53 pm
Location: Ukraine

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by Rucha »

Any idea how to change unit of Pressure value form mb to mm Hg?
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by Yincognito »

Rucha wrote: August 17th, 2021, 7:13 am Any idea how to change unit of Pressure value form mb to mm Hg?
Only mb (millibar) and in (inch) are available as units for atmospheric pressure on weather.com, as far as I know, but you can use a Calc measure to convert the already existing pressure measure value to mmHg:

Code: Select all

[PressuremmHg]
Measure=Calc
Formula=(Pressuremb*750.062)
DynamicVariables=1
Obviously, you'll change Pressuremb to whatever the name of your mb returning pressure measure is, and use this new "PressuremmHg" measure instead of the old one in the MeasureName options of the corresponding meters.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by sl23 »

I just wondered if it would be ok to edit this, to suit my Rounded suite, for sharing?
If not I'd still like to add it to that suite, but will not share it. All credits will remain.

Thanks
- MuLab -
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by jsmorley »

sl23 wrote: September 13th, 2021, 4:56 pm I just wondered if it would be ok to edit this, to suit my Rounded suite, for sharing?
If not I'd still like to add it to that suite, but will not share it. All credits will remain.

Thanks
Use this code any way at all that you want to!
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by sl23 »

:thumbup: :D
- MuLab -
leofender
Posts: 2
Joined: November 28th, 2021, 2:40 pm

Re: ⭐ Weather.com - Parsing the V3 JSON - NEW!

Post by leofender »

First of all sorry for my English, I am using a translator.

My question is because the orange symbol does not appear on the skin, if the weather.com page itself indicates it:

Image

Image

Taking a look at the API file I see that it indicates 4 in one section and 2 in another:

"eventDescription":"Alteración potencial debido a acontecimiento costero","severityCode":4,"severity":"Minor","categories":[{"category":"Met","categoryCode":2}],"responseTypes":[{"responseType":"Avoid","responseTypeCode":5}]

Are the alerts settings on the skin correct or is it a Weather.com bug?

Greetings, thanks and sorry for the inconvenience.