As per the docs, Douglas Crawford and Tobie Langel are the authors for
the JSON text regex, which is enforced with:
JSON.decode.(string, {secure : true})
where:
.decode : function { ...
if (secure && !(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test
(string.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''))) return
null;
...
}
So, anyone care to translate the regex? Would be neat if I could get
a description in English. I'm ok at regex generally...
All of this took me a while to find as to why I was getting a null
object in my
new Request.JSON({ onComplete : function(json, txt){
}
})
txt was coming through fine in my case where I did JSON.decode on it
locally (where default secure = false.) Couldn't figure this out,
until I set the Request.JSON option secure = false. (true is the
default in that instance).
Other JSON.Request onCompletes were doing fine with delivering JSON
objects (as they must have passed the tuest). Took me a while to find
and figure out the secure option.
- - -
Finally two questions:
1) Anyone have a link to an explanation on what hazardous JSON syntax
is (beyond the regex text boolean? )
2) Why was the decision made for Request.JSON to have {secure :
true} be the default? (An error would be better than null, IMHO when
secure = true...)
- Hunter