#1039 ✓resolved
Stephan Beal

JSON.stringify() incorrectly JSONizes empty arrays when Prototype is imported

Reported by Stephan Beal | April 20th, 2010 @ 07:02 PM


The expected result is: '{"a":[]}'

The result when using Prototype is: '{"a":"[]"}'

The extra quotes break 3rd-party code which tries to de-JSON that invalid result.

i have seen the same problem in the Mootools, but not in jQuery, dojo, nor when using the json2.js from Douglas Crockford ("the standard").

As soon as i import Prototype (or Mojo) into a web page, ALL JSONizing of empty arrays breaks. i assume this has something to do with Prototype/Mojo adding Array.prototype.toJSON(), but not quite doing it correctly.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

People watching this ticket