By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,463 Members | 2,954 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,463 IT Pros & Developers. It's quick & easy.

json > minus, colon, plus character key problem

P: n/a
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... :/
Apr 30 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Apr 30, 1:44 am, "Marc" <sorry...@dirtymail.comwrote:
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']);

Apr 30 '07 #2

P: n/a
"scripts.contact" <sc*************@gmail.comwrote in message
news:11**********************@o5g2000hsb.googlegro ups.com...
On Apr 30, 1:44 am, "Marc" <sorry...@dirtymail.comwrote:
>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!!
Apr 30 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.