473,396 Members | 2,076 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,396 software developers and data experts.

JSON EVAL error in javascript

Here is a sampel of the JSON text being returned from an httpRequest

Expand|Select|Wrap|Line Numbers
  1. {"Results":
  2.   {"pubNeighborhhods":
  3.     {"Rows":[
  4.        {"intNeighborHoodID":1,"intBookID":1,"Name":"Blairgowrie","Latitude":"0","Longitude":"0","Country":"Australia","state":"Vic"}
  5.       ,{"intNeighborHoodID":2,"intBookID":1,"Name":"Crib point","Latitude":"0","Longitude":"0","Country":"Australia","state":"Vic"}
  6.       ,{"intNeighborHoodID":3,"intBookID":1,"Name":"Moorooduc","Latitude":"0","Longitude":"0","Country":"Australia","state":"Vic"}
  7.       ]
  8.     }
  9.   }
  10. }
the above is returned as one long string with no line breaks, i added those for readability

when i use eval() it causes "invalid label" error

I have read about this online and the only answer i find is to enclose the JSON string in parentheses "(" and ")"

when i do this i get the following error
"missing ) in parenthetical"

i have not found a solution to this issue although i have found a couple posts asking about it

thanks

bud
Apr 1 '07 #1
1 3180
mrhoo
428 256MB
The problem is in what you are feeding the eval.

For example-
var s='{Larry:"Howard",Curly:"Howard",Moe:"Howard"}';
eval(s) throws an invalid label error
eval("\'"+s+"\'") returns the string, and not an object

But eval("var O="+s) does not throw an error,
and O does return the object.

Change either the response text or the eval call to make an assignment
of the object.
Apr 1 '07 #2

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

Similar topics

1
by: George Jempty | last post by:
In my journal anyway: "JSON: Javascript Unusable by the Client" http://slashdot.org/~scriptify/journal/103074
16
by: G Matthew J | last post by:
http://htmatters.net/htm/1/2005/07/evaling-JSON.cfm This is more or less in response to Mr Crockford's admonition a few months ago, "fork if you must". Ironically, although in that usenet post...
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...
10
by: Frank Millman | last post by:
Hi all I am writing a multi-user accounting/business application, which uses sockets to communicate between server and client. The server contains all the business logic. It has no direct...
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: {...
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: Otto Wyss | last post by:
I've now been looking for a week for a simple but useful sample on how to get a list of entries (persons) via an XMLHttpRequest using Json/PHP on the server. So far I've found about a thousend...
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...
1
by: bizt | last post by:
Hi, Im currently looking to move into using JSON for AJAX instead of returning from the server a string like the following: 12345{This is a text string{true I prefer objects because I dont...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.