Reputation: 51820
Haaylp!
The Yahoo! Widgets spec says I can parse JSON objects using JSON.parse(). When I actually try this, and here is what I tried...
var parsed = JSON.parse('{"key": "value"}');
print (parsed);
for (p in parsed)
{
print ("prop: "+p);
}
I get:
ReferenceError: JSON is not defined
What's going on? Is further magic required?
Upvotes: 0
Views: 706
Reputation: 51820
Turns out that 'JSON' is not available until after the onLoad call completes. As far as I can surmise, this is an issue only on PCs and not Macs.
To use JSON, it does simply work out of the box, but to try it out you need to do it from a timer callback or something.
Upvotes: 0
Reputation: 10100
Have you set the widget to use 4.5 features? JSON object was introduced in 4.5, it's not available in the older versions of Y!WE.
<?xml version="1.0" encoding="UTF-8"?>
<widget>
<version>1.0</version>
<minimumVersion>4.5</minimumVersion>
<settings>
<setting name="debug" value="on"/>
</settings>
</widget>
Upvotes: 0