473,509 Members | 2,918 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JSON object not parsing in firefox

Hi
The JSON object I am using is as below . this object is returned after
an AJAX call

{"application" :[
{optionValue:"101", optionDisplay: "estmt"},
{optionValue:"11", optionDisplay: "Arif"},
{optionValue:"12", optionDisplay: "JC"}
]}
In the JS i am using the below code

data = ajaxRequest.responseText ;
var jsonOBJ = eval('(' + data + ')');
len = jsonOBJ.application.length ;
key = jsonOBJ.application[i].optionValue ;
value = jsonOBJ.application[i].optionDisplay ;
Internet Explorer is able to process the above code , but while trying
from Firefox , I am getting the below error message

jsonOBJ has no properties
[Break on this error] len = jsonOBJ.application.length ;

Please help

Thanks
S

Sep 27 '07 #1
11 11199
On Sep 27, 1:57 pm, saril...@gmail.com wrote:
Hi
The JSON object I am using is as below . this object is returned after
an AJAX call

{"application" :[
{optionValue:"101", optionDisplay: "estmt"},
{optionValue:"11", optionDisplay: "Arif"},
{optionValue:"12", optionDisplay: "JC"}
]}

In the JS i am using the below code

data = ajaxRequest.responseText ;
var jsonOBJ = eval('(' + data + ')');
len = jsonOBJ.application.length ;
key = jsonOBJ.application[i].optionValue ;
value = jsonOBJ.application[i].optionDisplay ;

Internet Explorer is able to process the above code , but while trying
from Firefox , I am getting the below error message

jsonOBJ has no properties
[Break on this error] len = jsonOBJ.application.length ;

Please help

Thanks
S
I couldn't break Firefox with this:

var data = '{"application" :[\n\r{optionValue:"101", optionDisplay:
"estmt"},\n\r {optionValue:"11", optionDisplay: "Arif"},\n\r
{optionValue:"12", optionDisplay: "JC"}\n\r ]}';
var jsonOBJ = eval('(' + data + ')');
len = jsonOBJ.application.length;
alert(len);

Are you sure about the responseText value?

Sep 27 '07 #2
On Sep 27, 11:11 am, David Mark <dmark.cins...@gmail.comwrote:
On Sep 27, 1:57 pm, saril...@gmail.com wrote:


Hi
The JSON object I am using is as below . this object is returned after
an AJAX call
{"application" :[
{optionValue:"101", optionDisplay: "estmt"},
{optionValue:"11", optionDisplay: "Arif"},
{optionValue:"12", optionDisplay: "JC"}
]}
In the JS i am using the below code
data = ajaxRequest.responseText ;
var jsonOBJ = eval('(' + data + ')');
len = jsonOBJ.application.length ;
key = jsonOBJ.application[i].optionValue ;
value = jsonOBJ.application[i].optionDisplay ;
Internet Explorer is able to process the above code , but while trying
from Firefox , I am getting the below error message
jsonOBJ has no properties
[Break on this error] len = jsonOBJ.application.length ;
Please help
Thanks
S

I couldn't break Firefox with this:

var data = '{"application" :[\n\r{optionValue:"101", optionDisplay:
"estmt"},\n\r {optionValue:"11", optionDisplay: "Arif"},\n\r
{optionValue:"12", optionDisplay: "JC"}\n\r ]}';
var jsonOBJ = eval('(' + data + ')');
len = jsonOBJ.application.length;
alert(len);

Are you sure about the responseText value?- Hide quoted text -

- Show quoted text -
Hi
Thanks for the reply . I am geting the responseText value as below

{"application" :[ {optionValue:"101", optionDisplay: "estmt"},
{optionValue:"11", optionDisplay: "Arif"
},{optionValue:"12", optionDisplay: "JC"}]}
jsonOBJ has no properties
[Break on this error] len = jsonOBJ.application.length ;

appreciate your help

Sep 27 '07 #3
On Sep 27, 2:31 pm, saril...@gmail.com wrote:
On Sep 27, 11:11 am, David Mark <dmark.cins...@gmail.comwrote:


On Sep 27, 1:57 pm, saril...@gmail.com wrote:
Hi
The JSON object I am using is as below . this object is returned after
an AJAX call
{"application" :[
{optionValue:"101", optionDisplay: "estmt"},
{optionValue:"11", optionDisplay: "Arif"},
{optionValue:"12", optionDisplay: "JC"}
]}
In the JS i am using the below code
data = ajaxRequest.responseText ;
var jsonOBJ = eval('(' + data + ')');
len = jsonOBJ.application.length ;
key = jsonOBJ.application[i].optionValue ;
value = jsonOBJ.application[i].optionDisplay ;
Internet Explorer is able to process the above code , but while trying
from Firefox , I am getting the below error message
jsonOBJ has no properties
[Break on this error] len = jsonOBJ.application.length ;
Please help
Thanks
S
I couldn't break Firefox with this:
var data = '{"application" :[\n\r{optionValue:"101", optionDisplay:
"estmt"},\n\r {optionValue:"11", optionDisplay: "Arif"},\n\r
{optionValue:"12", optionDisplay: "JC"}\n\r ]}';
var jsonOBJ = eval('(' + data + ')');
len = jsonOBJ.application.length;
alert(len);
Are you sure about the responseText value?- Hide quoted text -
- Show quoted text -

Hi
Thanks for the reply . I am geting the responseText value as below

{"application" :[ {optionValue:"101", optionDisplay: "estmt"},
{optionValue:"11", optionDisplay: "Arif"

},{optionValue:"12", optionDisplay: "JC"}]}

jsonOBJ has no properties
[Break on this error] len = jsonOBJ.application.length ;

appreciate your help
So try what I did. Does it work for you?

Sep 27 '07 #4
Thomas 'PointedEars' Lahn wrote:
Thomas 'PointedEars' Lahn wrote:
>sa******@gmail.com wrote:
>>[...] I am geting the responseText value as below

{"application" :[ {optionValue:"101", optionDisplay: "estmt"},
{optionValue:"11", optionDisplay: "Arif"
},{optionValue:"12", optionDisplay: "JC"}]}
Evaluating that results in a compile error:

| Error: invalid label

Tested in Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7)
Gecko/20070914 Firefox/2.0.0.7 (with Firebug 1.05).

In contrast,

[ {optionValue:"101", optionDisplay: "estmt"}, {optionValue:"11",
optionDisplay: "Arif"},{optionValue:"12", optionDisplay: "JC"}]

evaluates fine.

{application: [ {optionValue:"102", optionDisplay: "estmt"},
{optionValue:"11", optionDisplay: "Arif"},{optionValue:"12", optionDisplay:
"JC"}]}

is OK, too.
I presume the reason why it breaks with `"application":' is that the outer
`{...}' is regarded as delimiters of a block statement by eval(), and not as
delimiters of the Object literal notation. Hence eval()uating the variant
with `application:' yields only the Array object, which has no `application'
property. Both `"application":' and `application:' are merely regarded as
labels in a block statement there, with the former being invalid.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Sep 27 '07 #5
On Sep 27, 12:26 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
Thomas 'PointedEars' Lahn wrote:
Thomas 'PointedEars' Lahn wrote:
saril...@gmail.com wrote:
[...] I am geting the responseText value as below
>{"application" :[ {optionValue:"101", optionDisplay: "estmt"},
{optionValue:"11", optionDisplay: "Arif"
},{optionValue:"12", optionDisplay: "JC"}]}
Evaluating that results in a compile error:
| Error: invalid label
Tested in Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7)
Gecko/20070914 Firefox/2.0.0.7 (with Firebug 1.05).
In contrast,
[ {optionValue:"101", optionDisplay: "estmt"}, {optionValue:"11",
optionDisplay: "Arif"},{optionValue:"12", optionDisplay: "JC"}]
evaluates fine.
{application: [ {optionValue:"102", optionDisplay: "estmt"},
{optionValue:"11", optionDisplay: "Arif"},{optionValue:"12", optionDisplay:
"JC"}]}
is OK, too.

I presume the reason why it breaks with `"application":' is that the outer
`{...}' is regarded as delimiters of a block statement by eval(), and not as
delimiters of the Object literal notation. Hence eval()uating the variant
with `application:' yields only the Array object, which has no `application'
property. Both `"application":' and `application:' are merely regarded as
labels in a block statement there, with the former being invalid.

PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16- Hide quoted text -

- Show quoted text -
Hi
I got the solution . tried without quotes and it worked fine . Thanks
to all for the help

S

Sep 27 '07 #6
sa******@gmail.com wrote:
[...] Thomas 'PointedEars' Lahn [...] wrote:
>I presume the reason why it breaks with `"application":' is that the outer
`{...}' is regarded as delimiters of a block statement by eval(), and not as
delimiters of the Object literal notation. Hence eval()uating the variant
with `application:' yields only the Array object, which has no `application'
property. Both `"application":' and `application:' are merely regarded as
labels in a block statement there, with the former being invalid.
[...]
Please trim your quotes. http://jibbering.com/faq/
Hi
I got the solution . tried without quotes and it worked fine . Thanks
to all for the help
I don't think you have relized yet that you are shooting yourself in the
foot. As I have pointed out, because of the block statement - object
literal and property name - label ambiguities, `jsonOBJ.application.length'
may or may not work with unquoted `application', depending on the script
engine that compiles this. You should use JSON.parse() instead.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Sep 27 '07 #7
On Sep 27, 2:45 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
saril...@gmail.com wrote:
[...] Thomas 'PointedEars' Lahn [...] wrote:
I presume the reason why it breaks with `"application":' is that the outer
`{...}' is regarded as delimiters of a block statement by eval(), and not as
delimiters of the Object literal notation. Hence eval()uating the variant
with `application:' yields only the Array object, which has no `application'
property. Both `"application":' and `application:' are merely regarded as
labels in a block statement there, with the former being invalid.
[...]

Please trim your quotes. http://jibbering.com/faq/
Hi
I got the solution . tried without quotes and it worked fine . Thanks
to all for the help

I don't think you have relized yet that you are shooting yourself in the
foot. As I have pointed out, because of the block statement - object
literal and property name - label ambiguities, `jsonOBJ.application.length'
may or may not work with unquoted `application', depending on the script
engine that compiles this. You should use JSON.parse() instead.

PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
I did not use JSON.parse() as it was throwing exceptions in firefox .
But when i unquoted the 'application' , i am able to parse the
jsonOBJ . Do you have any snippets to handle JSON.parse()
exception ?

Thanks
S

Sep 27 '07 #8
sa******@gmail.com wrote:
I did not use JSON.parse() as it was throwing exceptions in firefox .
But when i unquoted the 'application' , i am able to parse the
jsonOBJ . Do you have any snippets to handle JSON.parse()
exception ?
try
{
ajaxRequest.responseText.parseJSON()
}
catch (e)
{
// ...
}
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Sep 29 '07 #9
Thomas 'PointedEars' Lahn said the following on 9/29/2007 9:16 AM:
sa******@gmail.com wrote:
>I did not use JSON.parse() as it was throwing exceptions in firefox .
But when i unquoted the 'application' , i am able to parse the
jsonOBJ . Do you have any snippets to handle JSON.parse()
exception ?

try
Error prone on the web.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Sep 29 '07 #10
Randy Webb wrote:
Thomas 'PointedEars' Lahn said the following on 9/29/2007 9:16 AM:
>sa******@gmail.com wrote:
>>I did not use JSON.parse() as it was throwing exceptions in firefox .
^^^^^^^^^^^^^^^^^^^
>>But when i unquoted the 'application' , i am able to parse the
jsonOBJ . Do you have any snippets to handle JSON.parse()
exception ?
try

Error prone on the web.
Because of NN/IE 4.x?

It adds no more error-proneness here because -- surprise, surprise! -- the
current JSON parser implementation in J(ava)Script already uses `throw' to
throw the aforementioned exception:

http://www.json.org/js.html

The incompatibility with try...catch in ECMAScript < 3 implementations can
be worked around proprietarily with window.onerror and eval(), though.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Sep 30 '07 #11
Thomas 'PointedEars' Lahn said the following on 9/30/2007 5:02 AM:
Randy Webb wrote:
>Thomas 'PointedEars' Lahn said the following on 9/29/2007 9:16 AM:
>>sa******@gmail.com wrote:
I did not use JSON.parse() as it was throwing exceptions in firefox .
^^^^^^^^^^^^^^^^^^^
>>>But when i unquoted the 'application' , i am able to parse the
jsonOBJ . Do you have any snippets to handle JSON.parse()
exception ?
try
Error prone on the web.

Because of NN/IE 4.x?
Are you saying that you believe that NN4.x and IE4.x are the only
browsers potentially being used that don't support try/catch? try/catch
is error prone on the web.
It adds no more error-proneness here because -- surprise, surprise! -- the
current JSON parser implementation in J(ava)Script already uses `throw' to
throw the aforementioned exception:
That doesn't make try/catch/throw any less error prone.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Sep 30 '07 #12

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

Similar topics

20
6808
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... ...
54
8235
by: VK | last post by:
Mission statement: A mechanics to get text stream into browser from any Web location without reloading the current page. 1) This mechanics has to support *at the very least* IE 5.5 and higher...
5
1682
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...
10
2971
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...
1
1714
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...
2
6851
by: phil.swenson | last post by:
I'm using Prototype.js and would like to convert the contents of an HTML table to JSON. Converting to an array first is fine too. Any thoughts on this? I haven't seen anyone do anything this.......
23
3171
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...
1
3081
by: s481797 | last post by:
Hello, I'm having troubles with parsing my JSON object. Below you'll find my JSON string: {"email":{"invalid":"wrong email"}} I can get 'wrong email' using javascript by simply executing...
6
2807
by: Lasse Reichstein Nielsen | last post by:
Max <adsl@tiscali.itwrites: Not really. It shows that a particularly naïve implementation of a conversion from XML to JSON doesn't work well. What if the conversion of <e> some
0
7234
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
7136
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
7344
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,...
1
7069
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
5652
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
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...
0
4730
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1570
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.