473,386 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

json > minus, colon, plus character key problem

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
2 4388
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Douglas Crockford | last post by:
There is a new version of JSON.parse in JavaScript. It is vastly faster and smaller than the previous version. It uses a single call to eval to do the conversion, guarded by a single regexp test to...
5
by: Dominic Myers | last post by:
In the full and frank knowledge that someone will doubtless refer me to google and probably tell me to wipe my own arse I was wondering if someone could shed some light on the following problem...
5
by: Ryan | last post by:
{"POINTID":77902,"MAPID":762,"LONG":-122.21654892,"LAT":"37.1834331019","CITY":"Boulder Creek","STATE":"CA","DIST":5745.4} I get an "invalid label" error... I'm kinda new to this. Thanks!
0
by: heplesser | last post by:
Summary: Does the C++ standard require std::basic_istream<>::operator>>(double&) to leave the input stream untouched in case of a read failure? Details: I noticed an unexpected behavior of...
26
by: machineghost | last post by:
First off, let me just say that as someone with no DBA training whatsoever, any help I can get with this issue will be very, very much appreciated. My company recently migrated our database from...
1
by: Max | last post by:
Douglas Crockford ha scritto: Thank you Douglas. I hope to find a solution to implement a Javascript converter from XML to JSON. (Pay attention to page examples on json.org because there are...
5
by: Nick S | last post by:
Hi Is there anyway to iterate through a json object and retrieve the name of the property as well as the value. For exampe. Imagine this object { title: '1', bedrooms: '2',
2
by: MOS1 | last post by:
Folks Please help this is driving me insane The + expands but the minus fails Error src is null or not an object function Win_onLoad() { GetNameAndLink(0); } function GetNameAndLink(pkId)
1
by: dorandoran | last post by:
The sort on the childgrid is not working; nothing happens when I click on the each column header for sort. (I followed Satay's sample: http://www.codeproject.com/KB/aspnet/EditNestedGridView.aspx)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.