It is currently June 30th, 2024, 6:21 am

⭐ Weather.com - Parsing the V3 JSON

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

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by jsmorley »

VClouds wrote: June 7th, 2020, 1:14 pm Ha ha, unfortunately the parsing part is out of my league but at least I did manage to point out the problem... :oops: :thumbup:
Yes, you certainly did. Check the new .rmskin in the first post.
User avatar
Pflosch
Posts: 39
Joined: May 24th, 2020, 7:04 am
Location: Switzerland

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by Pflosch »

jsmorley wrote: June 7th, 2020, 12:35 pm Yeah, the whole en-GB thing throws a new wrinkle into this. Before, it felt safest to use en-GB to get "metric" instead of en-US to get "imperial", as the language-based text should be pretty similar. With the new "hybrid" units of measure they use for en-GB, it might be much safer to use en-CA or en-AU or something, to get pure "metric", while having some hope that the text and phrases used will be familiar to a US English speaker.
Yes, as usual, you nailed it.
If I switch to en-CA, both work correctly, the speeds and the pressure.
Thanks heaps.
I think maybe no problem.
User avatar
VClouds
Posts: 78
Joined: April 7th, 2010, 2:34 pm

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by VClouds »

jsmorley wrote: June 7th, 2020, 1:16 pm Yes, you certainly did. Check the new .rmskin in the first post.
Great I will check it out, thanks!
User avatar
Yincognito
Rainmeter Sage
Posts: 7576
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by Yincognito »

VClouds wrote: June 7th, 2020, 1:14 pm Ha ha, unfortunately the parsing part is out of my league but at least I did manage to point out the problem... :oops: :thumbup:
Yeah, no worries - identifying the problem is no doubt the first step in solving it. :thumbup:
Personally, I admit not checking the regexes in jsmorley's skin, since I don't use them - shame on me. :lol:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
xenium
Posts: 873
Joined: January 4th, 2018, 9:52 pm

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by xenium »

jsmorley wrote: June 7th, 2020, 12:12 pm
xxenium is with some of his still parsing the HTML from the site, and I expect there could be some subtle differences between the HTML and the JSON.
My skin uses JSON, it no longer uses HTML.
User avatar
jsmorley
Developer
Posts: 22642
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by jsmorley »

xenium wrote: June 7th, 2020, 1:25 pm My skin uses JSON, it no longer uses HTML.
I think that particular person might be using one of the older skins you haven't changed yet. Not sure.

Let me know when you get all your excellent skins fully corrected, so I can indicate that on the thread that lists them.
User avatar
Yincognito
Rainmeter Sage
Posts: 7576
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by Yincognito »

By the way, just in case it is needed, a (so far) foolproof way of handling commas in the string values, without affecting other non-string ones:

Code: Select all

(?:[^"]*|(?:(?:\\"|[^"])*"){2}),
You can, of course, replace the comma at the end with a more comprehensive form of the delimiter at the end of the value:

Code: Select all

(?:,|\{|\[|\]|\}|$)
By the way, this handles the escaped quotes (i.e. \") in the string value as well (the job of converting them to literal quotes is another matter, naturally), according to the JSON specification. I'm using these patterns as variables, to simplify the code.

Again, only if you need it. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22642
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by jsmorley »

Yincognito wrote: June 7th, 2020, 1:32 pm By the way, just in case it is needed, a (so far) foolproof way of handling commas in the string values, without affecting other non-string ones:

Code: Select all

(?:[^"]*|(?:(?:\\"|[^"])*"){2}),
You can, of course, replace the comma at the end with a more comprehensive form of the delimiter at the end of the value:

Code: Select all

(?:,|\{|\[|\]|\}|$)
By the way, this handles the escaped quotes (i.e. \") in the string value as well (the job of converting them to literal quotes is another matter, naturally), according to the JSON specification. I'm using these patterns as variables, to simplify the code.

Again, only if you need it. ;-)
We will see if we run into trouble. So far at least, it seems to handle commas in strings just fine.


1.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
VClouds
Posts: 78
Joined: April 7th, 2010, 2:34 pm

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by VClouds »

jsmorley wrote: June 7th, 2020, 1:16 pm Yes, you certainly did. Check the new .rmskin in the first post.
Downloaded and replaced your updated templates and the conditions are fixed.
now Fair is Fair and not Partly Cloudy... :sly:
Thanks!
User avatar
jsmorley
Developer
Posts: 22642
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by jsmorley »

VClouds wrote: June 7th, 2020, 2:02 pm Downloaded and replaced your updated templates and the conditions are fixed.
now Fair is Fair and not Partly Cloudy... :sly:
Thanks!
Fair enough...