This project is archived and is in readonly mode.

#796 ✓wontfix
Roman

(mootools) JSON.encode Vs (json2-json.org) JSON.stringify

Reported by Roman | November 26th, 2009 @ 12:51 AM | in 2.0 (closed)

Hi,

I was under the assumption that MooTools "encode" is functionality-wise compatible with the json2 JS library from http://www.json.org/js.html.

There is a bug (?) where when a form field (or any object parameter value..) is equal to " (single double quote) the result of (mootools') JSON.encode will not escape it, ie:

var a = 'this is " a double quote'
JSON.encode(a) == 'this is " a double quote'

While if I use the JSON2 library from json.org the result would be as expected: (note the same name space JSON..)

JSON.stringify(a) == 'this is " a double quote'

Is this a "feature" or a bug? :)
My vote goes for a bug, since if I am using mootools and encoding a form into JSON to be sent to a server, and the user used a single double quote (sometimes legitimately used as part of a name) will cause an error...

What say you?

Cheers,
Roman

Comments and changes to this ticket

Create your profile

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

Shared Ticket Bins

People watching this ticket

Pages