I took a sample json string from: http://www.json.org/example.html
{"web-app": {
"servlet": [
{
"servlet-name": "cofaxCDS",
"servlet-class": "org.cofax.cds.CDSServlet",
"init-param": { etc...
And parse that creating a html treeview, if I try and get a value:
alert(json.web-app.servlet[0].servlet-name);
the minus in 'web-app' is giving problems.
The toJSONString and parseJSON functions I'm using found on the same site do
not escape the key's
http://www.json.org/json.js
This must be a no brainer but I've been staring at this problem for so long
I just don't see a solution... :/
scripts.contact - 30 Apr 2007 09:01 GMT
> if I try and get a value:
> alert(json.web-app.servlet[0].servlet-name);
> the minus in 'web-app' is giving problems.
alert(json['web-app'].servlet[0]['servlet-name']);
Marc - 30 Apr 2007 09:43 GMT
>> if I try and get a value:
>> alert(json.web-app.servlet[0].servlet-name);
>> the minus in 'web-app' is giving problems.
>
> alert(json['web-app'].servlet[0]['servlet-name']);
Oooohhhh... if was sooo... close! Thx a lot!!