It is currently March 29th, 2020, 12:08 am

⭐ weather.com - Parsing the JSON

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

Re: ⭐ weather.com - Parsing the JSON

Post by jsmorley »

Ok, I moved to getting the "first" latitude / longitude in the Location section of the JSON.

Code: Select all

(?siU)"Location":{.*"latitude":(.*),.*"longitude":(.*),.*"displayName":(.*),.*"adminDistrict":(.*),.*"adminDistrictCode":(.*),.*"country":(.*),.*"countryCode":(.*),.*"Observation":.*language:(.*):.*"timeZoneAbbreviation":(.*)}
New .rmskin in the first post of this thread.
User avatar
jsmorley
Developer
Posts: 20425
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ weather.com - Parsing the JSON

Post by jsmorley »

So I think this demonstrates the practical difference.

When I look at the "first" Lat/Long in the Location information, the one that is presumably based on the location code (USVA0944) I am using, I get this:


1.png


So it's in the "center" of the "area" called "Fort Hunt". 4 minutes away. Good deal. Howdy neighbor!



When I look at the "second" Lat/Long in the Location information, the one presumably based on the "nearest city" to my location, I get this:


2.png


It's in the "center" of the "city" of "Alexandria". 14 minutes away. Not as good. They speak with an accent and wear funny shoes that far away...
You do not have the required permissions to view the files attached to this post.
User avatar
SilverAzide
Posts: 713
Joined: March 23rd, 2015, 5:26 pm

Re: ⭐ weather.com - Parsing the JSON

Post by SilverAzide »

Thank you! :thumbup:
DeviantArt Gadgets More...
User avatar
jsmorley
Developer
Posts: 20425
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ weather.com - Parsing the JSON

Post by jsmorley »

Sure. Oh, I also just added a link to the "location name" stuff in the context menu of my skin, which will take you to the location in Google Maps.
User avatar
jsmorley
Developer
Posts: 20425
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ weather.com - Parsing the JSON

Post by jsmorley »

Code: Select all

ContextTitle=[@LocationName], [@LocationAdminDistrict], [@LocationCountry]
ContextAction=https://www.google.com/maps/search/[@LocationLatitude],[@LocationLongitude]
Booyah!
User avatar
SilverAzide
Posts: 713
Joined: March 23rd, 2015, 5:26 pm

Re: ⭐ weather.com - Parsing the JSON

Post by SilverAzide »

Got it! ;-) Apparently small boats are falling from the sky near you, so.... duck.
DeviantArt Gadgets More...
User avatar
jsmorley
Developer
Posts: 20425
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ weather.com - Parsing the JSON

Post by jsmorley »

SilverAzide wrote:
February 20th, 2020, 11:12 pm
Got it! ;-) Apparently small boats are falling from the sky near you, so.... duck.
I hate it when that happens.
User avatar
Yincognito
Posts: 1070
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: ⭐ weather.com - Parsing the JSON

Post by Yincognito »

Brilliant! For now, this new "system" does not seem to have any disadvantages, and has complete data in both subsections of "Location" (no null fields), so one might as well take everything from the 1st subsection, not just latitude, longitude and displayName. I'll do just that in my skins, if this behavior turns out to be persistent.

Another advantage is that one can integrate his own "location search" InputText in a "settings skin", which will automatically add / change the latitude and longitude suffix in TWC's URL after parsing the XML / JSON provided by the API that SilverAzide mentioned earlier. No more confusing codes, power to the geo coordinates!

Nice work, both of you! :thumbup:
User avatar
Sabertooth
Posts: 31
Joined: April 5th, 2010, 5:09 am

Re: ⭐ weather.com - Parsing the JSON

Post by Sabertooth »

Greetings!

I adjusted my weather ini using your JSON parsing and it's working well but I notice that there's no Wind Gust data. @CurrentWindGust doesn't seem to have a value no matter the location (looking at the About Rainmeter/Skins/WeatherComJSON data). I tried different location values (Florida 33418, Virginia 22308, NY 11762) using your provided files but that always seems to come up empty. I only just started looking things over so I'm not sure where the problem is yet.

Edit: Looks like weather.com is returning a null.
SCR
Posts: 44
Joined: April 15th, 2015, 11:13 pm

Re: ⭐ weather.com - Parsing the JSON

Post by SCR »

Sabertooth wrote:
March 26th, 2020, 6:58 pm
Greetings!

I adjusted my weather ini using your JSON parsing and it's working well but I notice that there's no Wind Gust data. @CurrentWindGust doesn't seem to have a value no matter the location (looking at the About Rainmeter/Skins/WeatherComJSON data). I tried different location values (Florida 33418, Virginia 22308, NY 11762) using your provided files but that always seems to come up empty. I only just started looking things over so I'm not sure where the problem is yet.

Edit: Looks like weather.com is returning a null.
I've had results from @CurrentWindGust so I know it works. Right now the wind is at 7 mph and no gust here. Weather.com returns a null when there isn't any data to return. It is entirely possible that the areas you checked are not experiencing wind gusts.

I'd give it some time. Many days go by here without wind gusts. However about a week or so ago I had gusts as high as 47 mph. Three days ago the wind was 9 mph and gusting at 18 mph. The @CurrentWindGust measure returned the correct value.