Strange problems with JSON and Safari

Giganews Newsgroups
Subject: Strange problems with JSON and Safari
Posted by:  Nick (nick.lemout…@gmail.com)
Date: Sun, 30 Mar 2008

I'm trying to develop an AJAX application for the iphone which uses
JSON (as it's smaller than passing around HTML or XML).

Problem is Safari's not playing nice with JSON.

I have this response from my script:

["Value 1","Value 2","Value 3","Value 4","Value 5"]

I've tried a couple of ways of parsing this into javascript values:

status = new Function("return "+xmlHttp.responseText)();

Which works fine in firefox and IE, this gives me an array. In safari
it returns a string, this means when I do status.length I get a count
of all the characters in the string.

I've even tried the YUI JSON library but I get the same result.

Has anyone been able to use JSON arrays in Safari?

Replies