473,396 Members | 1,924 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 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 11191
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
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
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
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
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
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
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
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
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
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
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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,...

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.