473,387 Members | 1,313 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,387 software developers and data experts.

problem with converting json string to json object using eval

i have a problem converting a json string that i get from a servlet into a json object using eval function of java script. any one please help me..........
Jun 20 '07 #1
2 3347
gits
5,390 Expert Mod 4TB
hi,

please be a little bit more specific ;) ... what is the problem?

kind regards ...
Jun 20 '07 #2
rnd me
427 Expert 256MB
Expand|Select|Wrap|Line Numbers
  1. var jsonString="{a:1,b:2,c:3}"
  2.  
  3. var jsonObj=eval (  "  (  " + jsonString + "  )  " );
  4.  
  5. alert(jsonObj.b) //alerts "2".
Jun 21 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: Luke Matuszewski | last post by:
Welcome As suggested i looked into JSON project and was amazed but... What about cyclical data structures - anybody was faced it in some project ? Is there any satisactional recomendation... ...
2
by: Kevin Newman | last post by:
Hello, I noticed that the JavaScript library for JSON posted on json.org (http://www.json.org/json.js) is modifying Object.prototype (adding a method - toJSONString). I thought this was...
2
by: radykl | last post by:
Can anyone explain me why you need to add open and close parenthesis to a JSON text in order to use eval() to parse it? For example: var json = "{a: 'abc', b: 'def'}"; var obj1 = eval("(" +...
3
by: Tom Cole | last post by:
I'm new to JSON but see how it can be an improvement over XML for some things. I've modified a test servlet to return the following string with a content type of text/x-json: { header: {...
1
by: Red Daly | last post by:
Hello group, I have been using JSON for a while and it has made many things a breeze. However, JSON does not natively describe certain things like pointers and custom types. I created a simple...
3
by: asleepatdesk | last post by:
Hi, I need some help here. When I try to eval() my AJAX returned JSON string, I continually get a javascript error "Expected )". Here's my JSON string: {"recs": }; My js function simply...
5
by: Tom Cole | last post by:
Let's say I have the following JSON string returned from a server-side process: { values: } I then create a JSON object from it using eval() (tell me if this is not what should be done). ...
9
by: eggie5 | last post by:
eval is not working on this JSON string: {"top":} {"car":} {"man":} data = eval('(' + json + ')'); What's wrong with the json string, is it 'cause it has no root?
2
by: vunet | last post by:
When implementing JSON as a form of data exchange between server and client, what security measures do I need to consider? For example, I have XMLHttpRequest returning JSON text from the server and...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.