Closed Bug 426718 Opened 16 years ago Closed 7 years ago

JSON too much comma

Categories

(Core :: DOM: Core & HTML, defect)

1.9.0 Branch
x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: pvacher, Assigned: sayrer)

Details

Attachments

(2 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5

Hello
I find a JSON bug in FF3 beta4 and beta5...
Method JSON.encode put a comma to the end of the last object propertie.

Thank
Pierre


Reproducible: Always

Steps to Reproduce:
var kJSONContractID = "@mozilla.org/dom/json;1";
var kJSONSVCIID = Components.interfaces.nsIJSON;
var JSON = Components.classes[kJSONContractID].getService(kJSONSVCIID);
var Obj = {propertie1: "value1", propertie2: "value2"};
var jsonStr = JSON.encode(Obj);
dump(jsonStr);

Actual Results:  
{"propertie1":"value1","propertie2":"value2",}

Expected Results:  
{"propertie1":"value1","propertie2":"value2"}
Component: General → DOM
Product: Firefox → Core
QA Contact: general → general
Version: unspecified → Trunk
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Assignee: nobody → sayrer
Status: ASSIGNED → NEW
It works with:

var Obj = {};
Obj.propertie1 = "value1";
Obj.propertie2 = "value2";

OR

var Obj = {"propertie1": "value1", "propertie2": "value2"};
This _might_ be the issue I'm seeing writing some of the new automation code. The simplejson parser for Python is barfing on JSON output from the native Mozilla JSON parser. I had to use the json2.js parser from crockford instead.
ug, I lost track of this. we'll get it asap.
Flags: wanted1.9.0.x?
I can't reproduce this on trunk. Can anyone get it in Firefox 3?

I will still add a test case for this, to prevent future occurrences.
Status: NEW → ASSIGNED
(In reply to comment #2)
> This _might_ be the issue I'm seeing writing some of the new automation code.
> The simplejson parser for Python is barfing on JSON output from the native
> Mozilla JSON parser. I had to use the json2.js parser from crockford instead.
> 

You should attach the input here...
I'm attaching two files, one is the JSON returned from json2.js , the other is the JSON returned by the native encoder which when I try to parse it with simplejson I get the following error;

ValueError: Expecting property name: line 1 column 23451 (char 23451)
Flags: wanted1.9.0.x? → wanted1.9.0.x+
I just hit this bug too.  I exported my bookmarks from FF 3.0.11 and they had the extra comma that made the Python simplejson parser barf.
This is fixed in trunk and 1.9.1, due to the new ES5 JSON codec (I hope)? I'm optimistically setting the Version field to reflect a "yes" answer.

/be
Version: Trunk → 1.9.0 Branch
yeah, this is fixed there.
Closing per earlier comments.
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → WORKSFORME
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: