# jsonDecode parsing not working in 7.8.3 but is in 7.8.1

**URL:** <https://forum.inductiveautomation.com/t/jsondecode-parsing-not-working-in-7-8-3-but-is-in-7-8-1/12282>\
**Category:** Ignition\
**Created:** [October 25, 2016, 10:26pm UTC](https://forum.inductiveautomation.com/t/jsondecode-parsing-not-working-in-7-8-3-but-is-in-7-8-1/12282 "2016-10-25T22:26:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RMAC](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@RMAC](https://forum.inductiveautomation.com/u/RMAC)\
**Post date:** [October 25, 2016, 10:26pm UTC](https://forum.inductiveautomation.com/t/jsondecode-parsing-not-working-in-7-8-3-but-is-in-7-8-1/12282/1 "2016-10-25T22:26:32Z")

</div>

I have two separate Ignition instances running identical code. 7.8.1 can parse a json stream from a http site and my 7.8.3 instance can not. In looking at the change log I could not find any system.util.jsonDecode improvements.

On the 7.8.1 instance json\_string is a json string and parsed\_jason is a dictionary (works as expected)  
On the 7.8.3 instance both are json strings and I do not receive any parsing errors. The last print statement does error because parsed\_jason is not a dictionary.  
Does anyone know why the two would run differently?

[code]

# Query Weather Underground for weather alerts

def getAlerts():  
import urllib2  
f = urllib2.urlopen(‘[http://api.wunderground.com/api/MyKeyCode/geolookup/alerts/q/IA/Orange\_City.json](http://api.wunderground.com/api/MyKeyCode/geolookup/alerts/q/IA/Orange_City.json)’)  
json\_string = f.read()  
f.close()  
parsed\_json = system.util.jsonDecode(json\_string)  
print json\_string  
print parsed\_json  
print "location: ", parsed\_json[‘location’][‘city’][/code]

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [October 25, 2016, 10:34pm UTC](https://forum.inductiveautomation.com/t/jsondecode-parsing-not-working-in-7-8-3-but-is-in-7-8-1/12282/2 "2016-10-25T22:34:57Z")

</div>

There were some (ostensibly) corrections made to the jsonDecode function at some point. I can’t say for sure if it’s now acting correctly or not without seeing the JSON you’re getting back and maybe what the object it’s being parsed into looks like.

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [October 25, 2016, 10:39pm UTC](https://forum.inductiveautomation.com/t/jsondecode-parsing-not-working-in-7-8-3-but-is-in-7-8-1/12282/3 "2016-10-25T22:39:46Z")

</div>

Looks like we did make some changes to jsonDecoding in 7.7.7, and those changes got pulled into 7.8.2. The change log entry from 7.7.7 says “Fixes bug in jsonDecode() that caused strings containing numbers to be decoded as numbers.” Not sure if that’s causing the difference you see, but it sure seems suspicious…

---

<div class="post-metadata">

**Author:** ![RMAC](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@RMAC](https://forum.inductiveautomation.com/u/RMAC)\
**Post date:** [October 25, 2016, 10:43pm UTC](https://forum.inductiveautomation.com/t/jsondecode-parsing-not-working-in-7-8-3-but-is-in-7-8-1/12282/4 "2016-10-25T22:43:03Z")

</div>

Here is the output from the URL. I’m trying to put it into a dictionary where I can grab storm warnings

`
 { "response": { "version":"0.1", "termsofService":"http://www.wunderground.com/weather/api/d/terms.html", "features": { "geolookup": 1 , "alerts": 1 } } ,	"location": { "type":"CITY", "country":"US", "country_iso3166":"US", "country_name":"USA", "state":"CA", "city":"Poway", "tz_short":"PDT", "tz_long":"America/Los_Angeles", "lat":"32.97999954", "lon":"-117.04000092", "zip":"92064", "magic":"1", "wmo":"99999", "l":"/q/zmw:92064.1.99999", "requesturl":"US/CA/Poway.html", "wuiurl":"https://www.wunderground.com/US/CA/Poway.html", "nearby_weather_stations": { "airport": { "station": [{ "city":"Ramona", "state":"CA", "country":"US", "icao":"KRNM", "lat":"33.03749847", "lon":"-116.91583252" } ,{ "city":"Miramar MCAS", "state":"CA", "country":"US", "icao":"KNKX", "lat":"32.86454010", "lon":"-117.13661194" } ,{ "city":"Santee", "state":"CA", "country":"US", "icao":"KSEE", "lat":"32.82622147", "lon":"-116.97244263" } ,{ "city":"San Diego Montgomery", "state":"CA", "country":"US", "icao":"KMYF", "lat":"32.81572342", "lon":"-117.13957977" }] } , "pws": { "station": [{ "neighborhood":"Midland Road Extension", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY67", "lat":32.982857, "lon":-117.040390, "distance_km":0, "distance_mi":0 }, { "neighborhood":"Midland Gardens", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY37", "lat":32.984116, "lon":-117.039978, "distance_km":0, "distance_mi":0 }, { "neighborhood":"Twin Circle Court", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY54", "lat":32.975670, "lon":-117.043198, "distance_km":0, "distance_mi":0 }, { "neighborhood":"Arbolitos", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY58", "lat":32.981564, "lon":-117.052002, "distance_km":1, "distance_mi":0 }, { "neighborhood":"Paseo De La Huerta", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY40", "lat":32.993382, "lon":-117.039864, "distance_km":1, "distance_mi":0 }, { "neighborhood":"Paseo De La Huerta", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY45", "lat":32.993511, "lon":-117.040161, "distance_km":1, "distance_mi":0 }, { "neighborhood":"Twin Peaks and Espola", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY30", "lat":32.978634, "lon":-117.020638, "distance_km":1, "distance_mi":1 }, { "neighborhood":"Beechwood Street", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY75", "lat":32.967670, "lon":-117.053741, "distance_km":1, "distance_mi":1 }, { "neighborhood":"Arbolitos", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY72", "lat":32.967579, "lon":-117.053673, "distance_km":1, "distance_mi":1 }, { "neighborhood":"Country Hill Road", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY83", "lat":32.988464, "lon":-117.017365, "distance_km":2, "distance_mi":1 }, { "neighborhood":"Adobe Hills", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY2", "lat":32.983601, "lon":-117.064819, "distance_km":2, "distance_mi":1 }, { "neighborhood":"Green Valley Highlands", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY16", "lat":33.001198, "lon":-117.037811, "distance_km":2, "distance_mi":1 }, { "neighborhood":"Green Valley Highlands DP2", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY32", "lat":33.001263, "lon":-117.037796, "distance_km":2, "distance_mi":1 }, { "neighborhood":"Eastern Poway", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY10", "lat":32.960861, "lon":-117.019798, "distance_km":2, "distance_mi":1 }, { "neighborhood":"Poway Rd/Midland", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY21", "lat":32.954250, "lon":-117.035683, "distance_km":2, "distance_mi":1 }, { "neighborhood":"APRSWXNET", "city":"Poway", "state":"CA", "country":"US", "id":"ME3241", "lat":32.960468, "lon":-117.019249, "distance_km":2, "distance_mi":1 }, { "neighborhood":"High Valley", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY88", "lat":32.992653, "lon":-117.010750, "distance_km":3, "distance_mi":1 }, { "neighborhood":"Parview Estates", "city":"San Diego", "state":"CA", "country":"US", "id":"KCASANDI589", "lat":32.995453, "lon":-117.068344, "distance_km":3, "distance_mi":1 }, { "neighborhood":"Green Valley Highlands North", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY42", "lat":33.008369, "lon":-117.036201, "distance_km":3, "distance_mi":1 }, { "neighborhood":"Bridlewood - Lake Poway", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY82", "lat":33.000904, "lon":-117.014694, "distance_km":3, "distance_mi":1 }, { "neighborhood":"Espola and Lake Poway Road", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY47", "lat":33.006817, "lon":-117.022911, "distance_km":3, "distance_mi":2 }, { "neighborhood":"MesoWest", "city":"Poway", "state":"CA", "country":"US", "id":"MSDPWE", "lat":32.994999, "lon":-117.008003, "distance_km":3, "distance_mi":2 }, { "neighborhood":"Lake Poway/Bridlewood", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY68", "lat":33.004658, "lon":-117.017868, "distance_km":3, "distance_mi":2 }, { "neighborhood":"Bridlewood", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY62", "lat":33.004608, "lon":-117.015739, "distance_km":3, "distance_mi":2 }, { "neighborhood":"8 Palms Ranchero Poway, CA", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY33", "lat":32.950218, "lon":-117.025726, "distance_km":3, "distance_mi":2 }, { "neighborhood":"Bridlewood American", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY85", "lat":33.009918, "lon":-117.025475, "distance_km":3, "distance_mi":2 }, { "neighborhood":"Bernardo Heights", "city":"San Diego", "state":"CA", "country":"US", "id":"KCASANDI160", "lat":32.994450, "lon":-117.075256, "distance_km":3, "distance_mi":2 }, { "neighborhood":"Poway Estates", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY9", "lat":32.954151, "lon":-117.064392, "distance_km":3, "distance_mi":2 }, { "neighborhood":"Bridlewood", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY89", "lat":33.012383, "lon":-117.027855, "distance_km":3, "distance_mi":2 }, { "neighborhood":"Carmel Mountain Ranch", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY86", "lat":32.969673, "lon":-117.078857, "distance_km":3, "distance_mi":2 }, { "neighborhood":"North Poway", "city":"Poway", "state":"CA", "country":"US", "id":"KCAPOWAY53", "lat":33.014328, "lon":-117.026520, "distance_km":4, "distance_mi":2 }, { "neighborhood":"APRSWXNET", "city":"Poway", "state":"CA", "country":"US", "id":"ME9437", "lat":33.000000, "lon":-117.000000, "distance_km":4, "distance_mi":2 }] } } } ,"query_zone": "050", "alerts": [] } `

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [October 25, 2016, 11:11pm UTC](https://forum.inductiveautomation.com/t/jsondecode-parsing-not-working-in-7-8-3-but-is-in-7-8-1/12282/5 "2016-10-25T23:11:07Z")

</div>

Call .strip() on your response JSON string before you decode it… it appears to be very sensitive when it comes to the first character and if it starts with a newline it doesn’t decode properly.

---

<div class="post-metadata">

**Author:** ![RMAC](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@RMAC](https://forum.inductiveautomation.com/u/RMAC)\
**Post date:** [October 25, 2016, 11:47pm UTC](https://forum.inductiveautomation.com/t/jsondecode-parsing-not-working-in-7-8-3-but-is-in-7-8-1/12282/6 "2016-10-25T23:47:37Z")

</div>

Works great! Here is my new code. Thanks for the help

[code]

# Query Weather Underground for weather alerts

def getAlerts():  
import urllib2  
f = urllib2.urlopen(‘[http://api.wunderground.com/api/MyKeyCode/geolookup/alerts/q/IA/Orange\_City.json](http://api.wunderground.com/api/MyKeyCode/geolookup/alerts/q/IA/Orange_City.json)’)  
json\_string = f.read()  
f.close()  
parsed\_json = system.util.jsonDecode(json\_string.strip())  
print json\_string  
print parsed\_json  
print "location: ", parsed\_json[‘location’][‘city’][/code]
