473,320 Members | 2,193 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.

JSON array problem

Hi, I have the following problem:
when I try to access to the array in Big object I have 'Big is not
defined'
but
when I try to access to the function in Low object I have no error!!!!
WHY??

Big =

{
One: [1, 2, 4],
Two: [1, Big.One, 5]

};

alert(Big.Tow) // error

Low =
{
One: function()
{

},
Two: function()
{
Low.One();
}
};

Low.Two(); // no error

Thank
Oct 24 '08 #1
2 2635
On 2008-10-24 11:42, xdevel1999 wrote:
Hi, I have the following problem:
when I try to access to the array in Big object I have 'Big is not
defined'
but
when I try to access to the function in Low object I have no error!!!!
WHY??
None of these are valid JSON objects; that's the main problem.

To answer your question: in the first case, 'Big' is not defined when
you try to access it (which is in the line "[1, Big.One, 5]"). In the
second case, 'Low' _is_ defined when you try to access it, which is in
the line "Low.Two();".
- Conrad
Oct 24 '08 #2
On 2008-10-24 13:02, xdevel1999 wrote:
>None of these are valid JSON objects; that's the main problem.

why is the syntax incorrect?
First of all, JSON is a text format. What you're using are object
literals. The JSON syntax is very simple, and completely described on
this page: http://www.json.org/

(in short: there are no functions and no references in JSON strings)
Yes I can understand but this works...I'm confused

Low =
{
One: function()
{
alert(Low.b); // here the object Low is not already defined!
True, but this line isn't executed yet. It will only be executed when
you call the function. In your earlier example, Big.One would be
evaluated immediately, before the interpreter knows what "Big" is.
- Conrad
Oct 24 '08 #3

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... ...
1
by: Ike | last post by:
Ive copied an online example for writing out a php file, programmatically, then would like to re-display that data in a browswer window that automatically refreshes as the data file (getdata.php,...
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...
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...
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...
3
by: xhe | last post by:
I found Jason is a very handy data format for client/server communication. But I just met a problem as follows: I want to read the data replied from server in Jason format, the reply is like...
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) {
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: 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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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: 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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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.