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

self evaluation of a json string

i've a problem with the following statement:
var eg=eval('('+strjson+')');
making debug with firebug, a firefox extension i got
typeof(strjson) "string" inspect(strjson)

{"data":"01\/05\/2006","tipo_selezionato":"premiazione",
"lista_orari":[{"id":"1","ora_inizio":"10:30","ora_fine":"14:3 0"}],
"1":{"dettaglio_evento":{"titolo":"premio birra","descrizione":"chi beve
birra campa 100 anni","tipo":"premiazione"}}}

(it's a JSON string without any linebreak)

getting this warning:

syntax error
mostra_minical.js (line 53)
()

Line 53 is the related statement

How can i resolve? The idea is not making use of any parser to import
json string as javascript object.

Thanx
fusillo
Jun 13 '06 #1
1 1557
fusillo ha scritto:
i've a problem with the following statement:
var eg=eval('('+strjson+')');
making debug with firebug, a firefox extension i got
typeof(strjson)
"string"
inspect(strjson)


{"data":"01\/05\/2006","tipo_selezionato":"premiazione",
"lista_orari":[{"id":"1","ora_inizio":"10:30","ora_fine":"14:3 0"}],
"1":{"dettaglio_evento":{"titolo":"premio birra","descrizione":"chi beve
birra campa 100 anni","tipo":"premiazione"}}}

(it's a JSON string without any linebreak)

getting this warning:

syntax error
mostra_minical.js (line 53)
()

Line 53 is the related statement

How can i resolve? The idea is not making use of any parser to import
json string as javascript object.

Thanx
fusillo


the problem was related to the asyncronous context of the statement..
I resolved it testing the existence of the variable before the eg's
declaration:
if (strjson){
eval("var eg="+strjson);
...
Jun 13 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

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...
3
by: Adam | last post by:
I'm trying to retrieve some values from a json object, but instead it's giving me the property name. For example: var json = { "glossary": { "title": "example glossary" } }; console.log(json);...
1
by: kungfumike | last post by:
Currently having a problem getting JSON to include properly. I When I attempt to call .toJSONstring on an array it was giving me an error. So I resorted to just alerting the array out to the screen...
1
by: seth | last post by:
Hi: I'm trying to read JSON strings sent from the browser. Here is the scenario: 1. Using YUI tookit 2. sending JSON string from YUI toolkit - using the provided asyncRequest method. **I...
23
by: dhtmlkitchen | last post by:
JSON We all know what it is. In ECMAScript 4, there's a JSON proposal: Object.prototype.toJSONString String.prototype.parseJSON The current proposal, String.prototype.parseJSON, returns...
7
by: Logos | last post by:
I am using PHP with the JSON extension function json_decode. I have a JSON with a member named "1" (ie) { "1":"somedata" } Trying to access this via the -operator doesn't work, nor does . ...
9
by: Jon Paal [MSMD] | last post by:
using json like ( {"Records": , "RecordCount":"1" } ) and jquery like: $.ajax({ .... success: function(json, status) {
0
by: crocodilu2008 | last post by:
JSON vs. XML JSON and XML are basically used for the same purpose—to represent and interchange data. I'll try to show you why you might want to use JSON rather than XML in an AJAX context by showing...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.