Parsing JSN files from weatherunderground

( no longer available as free service)

This is an example of parsing what was a free on-line sevice JSON file and interpreting /presenting the contents.
global j$

open "parse.json" for input as #fi
    j$ =input$( #fi, lof( #fi))
close #fi

print "       LB WEATHER STATION"
print " -92.58484650 degrees longitude"
print "  34.56635666 degrees latitude"
print "       295 feet elevation"
print ""
print " Current temperature is: "; val( json$( "temp_f")); "°F & feels like "; jsonQ$( "feelslike_f"); "°F."
print " Atmospheric pressure is: "; val( jsonQ$( "pressure_in")); " inches of Hg."
print " Wind speed is: "; val( json$( "wind_mph")); " mph, out of the "; jsonQ$( "wind_dir")
print " Wind is: "; jsonQ$( "wind_string")
print " Relative Humidity is: "; jsonQ$( "relative_humidity")
print " Rainfall Today was: "; jsonQ$( "precip_today_in"); " inches."

end

function json$( find$)  '   finds the data string immediately after this section-header
    startPtr =instr( j$, find$) +2 +len( find$)
    endPtr   =instr( j$, ",", startPtr)
    lenData  =endPtr -startPtr
    json$    =mid$( j$, startPtr, lenData)
end function

function jsonQ$( find$) '   finds the data string , but omitting leading/trailing quotes
    startPtr =instr( j$, find$) +2 +len( find$)
    endPtr   =instr( j$, ",", startPtr)
    lenData  =endPtr -startPtr
    jsonQ$    =mid$( j$, startPtr +1, lenData -2)
end function


{
"response": {
"version":"0.1",
"termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
"features": {
"conditions": 1
}
}
, "current_observation": {
"image": {
"url":"http://icons.wxug.com/graphics/wu2/logo_130x80.png",
"title":"Weather Underground",
"link":"http://www.wunderground.com"
},
"display_location": {
"full":"Sheridan, AR",
"city":"Sheridan",
"state":"AR",
"state_name":"Arkansas",
"country":"US",
"country_iso3166":"US",
"zip":"72150",
"magic":"1",
"wmo":"99999",
"latitude":"34.30760956",
"longitude":"-92.40081787",
"elevation":"86.00000000"
},
"observation_location": {
"full":"K5BTM - Sheridan, Sheridan, Arkansas",
"city":"K5BTM - Sheridan, Sheridan",
"state":"Arkansas",
"country":"US",
"country_iso3166":"US",
"latitude":"34.264088",
"longitude":"-92.391708",
"elevation":"295 ft"
},
"estimated": {
},
"station_id":"KARSHERI2",
"observation_time":"Last Updated on June 18, 2:54 PM CDT",
"observation_time_rfc822":"Sat, 18 Jun 2016 14:54:46 -0500",
"observation_epoch":"1466279686",
"local_time_rfc822":"Sat, 18 Jun 2016 15:01:19 -0500",
"local_epoch":"1466280079",
"local_tz_short":"CDT",
"local_tz_long":"America/Chicago",
"local_tz_offset":"-0500",
"weather":"Partly Cloudy",
"temperature_string":"95.2 F (35.1 C)",
"temp_f":95.2,
"temp_c":35.1,
"relative_humidity":"47%",
"wind_string":"From the NW at 2.2 MPH",
"wind_dir":"NW",
"wind_degrees":315,
"wind_mph":2.2,
"wind_gust_mph":0,
"wind_kph":3.5,
"wind_gust_kph":0,
"pressure_mb":"1018",
"pressure_in":"30.06",
"pressure_trend":"+",
"dewpoint_string":"72 F (22 C)",
"dewpoint_f":72,
"dewpoint_c":22,
"heat_index_string":"104 F (40 C)",
"heat_index_f":104,
"heat_index_c":40,
"windchill_string":"NA",
"windchill_f":"NA",
"windchill_c":"NA",
"feelslike_string":"104 F (40 C)",
"feelslike_f":"104",
"feelslike_c":"40",
"visibility_mi":"10.0",
"visibility_km":"16.1",
"solarradiation":"--",
"UV":"8","precip_1hr_string":"-999.00 in ( 0 mm)",
"precip_1hr_in":"-999.00",
"precip_1hr_metric":" 0",
"precip_today_string":"0.00 in (0 mm)",
"precip_today_in":"0.00",
"precip_today_metric":"0",
"icon":"partlycloudy",
"icon_url":"http://icons.wxug.com/i/c/k/partlycloudy.gif",
"forecast_url":"http://www.wunderground.com/US/AR/Sheridan.html",
"history_url":"http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=KARSHERI2",
"ob_url":"http://www.wunderground.com/cgi-bin/findweather/getForecast?query=34.264088,-92.391708",
"nowcast":""
}
}