Giter Club home page Giter Club logo

jquery-json's Introduction

npm Tested with QUnit

jQuery JSON

JSON plugin for jQuery, provides simple ways to convert to JSON and back again.

Usage

$.toJSON(myObject);
$.toJSON({ foo: 'bar' });

Development

To create the minified build, run this command from the root directory of the repository:

$ npm run build

Test

Open up ./test/index.html in your browser to run the test suite, or run it from the command line with Grunt:

$ npm install
$ npm test

For it to pass in modern browsers, you have to enable the disableNative option from the QUnit toolbar.

Also, before releasing. Make sure to test the minifed version as well, you can do so by enabling the distmin option in the QUnit toolbar. This will load the minified build from the ./dist/ directory instead of ./src/.

Versioning

We use the Semantic Versioning guidelines as much as possible.

Releases will be numbered in the following format:

<major>.<minor>.<patch>

For more information on SemVer, please visit http://semver.org/.

jquery-json's People

Contributors

deadwisdom avatar krinkle avatar nmg196 avatar paladox avatar zetoke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery-json's Issues

Need Demos/Examples

From jimgkraai on October 13, 2008 07:27:28

jquery-json is simple goodness, but when a quick solution is needed, some
kind of how-to would be a big time saver. What steps will reproduce the problem? 1. Download source
2. Search Google Code page and source for Demos/Examples
3. Fail

What is the expected output? http://www.prodevtips.com/2008/08/15/jquery-json-with-php-json_encode- and-json_decode/

What do you see instead?
Steps-to-reproduce (3) What version of the product are you using? On what operating system? jquery.json-1.2.js Please provide any additional information below. Great plugin--just what I needed!

Attachment: jquery.json-1.2-demo.html jquery.json-1.2-demo_target.php

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=4

A bug present in the $.quoteString() function - Use "string.match(pattern)" instead of "pattern.test(string)"

From cheton on July 15, 2009 14:29:08

There is a bug present in the $.quoteString() function while the following
JS code:

var arr = ["C:\A.TXT", "C:\B.TXT", "C:\C.TXT", "C:\D.TXT"];
alert($.toJSON(arr));

The expected output string should be
["C:\A.TXT","C:\B.TXT","C:\C.TXT","C:\D.TXT"]
but it looks like below:
["C:\A.TXT","C:\B.TXT","C:\C.TXT","C:\D.TXT"]

[ORIGINAL CODE]

Use a global regular expression to test string will cause
the "expression state" issue. However, put the expression inside the
function doesn't for Firefox if a global match is performed.

var escapeable = /["\x00-\x1f\x7f-\x9f]/g;
$.quoteString = function(string)
{
if (escapeable.test(string)) {
: : :
}

[SOLUTION]

The solution is to replace "pattern.test(string)" with "string.match
(pattern)" since the result of "pattern.test(string)" looks different
across browsers

var escapeable = /["\x00-\x1f\x7f-\x9f]/g;
$.quoteString = function(string)
{
if (string.match(escapeable)) {
: : :
}

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=20

$.toJSON error with attributed set to undefined

From adipi71 on May 03, 2011 18:41:25

What steps will reproduce the problem? 1. in xxx.js:
var a={"id":"xx", "desc": undefined}
$.toJSON(a);

What is the expected output?
{"id":"xx"}

What do you see instead?
{"id":"xx", "desc": undefined}
which is not JSON compliant

What version of the product are you using?
2.2

On what operating system?
any Please provide any additional information below. added a check in the code of $.toJSON.
...
var val = $.toJSON(o[k]);
if( val ){
pairs.push(name + ":" + val);
}
...

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=46

Date.toJSON missing the "" outside of YYYY-MM-DD

From jessige.27 on July 01, 2009 06:32:14

var object = $.toJSON({date: new Date(Date.parse("2009/06/22"))});
alert(object); // {"date": 2009-05-21}, it should be {"date": "2009-06-22"}
object = $.evalJSON(object);
alert(object.date); // 1983, a strange value

  1. why 2009-05-21, but not 2009-06-22?
  2. missing "", so the result of eval is wrong.

BTW, what is the parameter date used for?

Date.prototype.toJSON = function(date)
// Yes, it polutes the Date namespace, but we'll allow it here, as
// it's damned usefull.
{
    return this.getUTCFullYear()   + '-' +
         toIntegersAtLease(this.getUTCMonth()) + '-' +
         toIntegersAtLease(this.getUTCDate());
};

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=18

Too much recursion error

From rdohms on November 22, 2008 01:29:03

What steps will reproduce the problem?

  1. Convert a GMaps GLatLng object to JSON with the $toJSON() function
  2. Script becomes unresponsive

What is the expected output? What do you see instead?

It should enconde the object to json

What version of the product are you using? On what operating system?

version 1.3 both min and not Please provide any additional information below. Recursion happens here on line 92

too much recursion
http://localhost/web/groupdirectory/public/scripts/jplugins/jquery.json.js
Line 92

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=7

Sign removed in floating point number in 1.84467440737E+19

From bas.hopman on July 24, 2009 11:27:39

What steps will reproduce the problem? 1. Use toJSON to encode an object containing a number like 1.84467440737E+19 What is the expected output? What do you see instead? The expected result is: ',"dDefault":"1.84467440737E+19",' but I get
',"dDefault":"1.84467440737E 19",' instead. What version of the product are you using? On what operating system? jquery.json-1.3.min.js on FireFox 3.5 on Windows XP Pro English Please provide any additional information below. This "number" is stored as a string in my database. When displayed to the
screen (after retreiving it via JSON as well) JavaScript says "NAN" as it
apparently requires the '+'.

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=21

Quality code

From passcod3 on November 29, 2010 11:20:55

The quality of the code is deplorable. You should take a peek at Crockford's articles on the question. I have modified the code to comply with some of these recommendations, which make it easier to read and to extend. It now passes JSLint's test without errors (given the options at the top of the file, which disable eval() checking, even though eval is evil). It does increase the file size a bit, but shouldn't be a problem otherwise.

Attachment: jquery.json-2.2.js

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=45

$.addToJSON and $.removeFromJSON additions

From lorderunion on September 18, 2008 03:57:43

This is not a defect, my status as a non-developer prevents me from writing
enhancement tickets.

I'm currently writing an AJAX-y application and needed a way to
write/remove JSON data to a data store. So here is my contribution...

$.addToJSON(node, index, data);
Example: $.addToJSON($(document).find('input:hidden[someattr]'), id, {'id':
id, 'name': name});

This example would:

  1. Look up in the 'input:hidden[someattr]' node for existing JSON.
    1a. If there is not a valid JSON object in the lookup node already, it
    creates one and continues.
  2. Eval it with $.secureEvalJSON()
  3. Add the new index and accompanying data
  4. Re-store the updated JSON object with $.toJSON().

$.removeFromJSON(node, index);
Example: $.removeFromJSON($(document).find('input:hidden[someattr]'), someid);

This example would:

  1. Lookup in the 'input:hidden[someattr]' node for JSON.
    1a. If no JSON is found, return.
  2. If it finds JSON, it looks for the key corresponding to the passed
    'index' argument.
    2a. If no JSON is found, return.
  3. Delete the requested JSON key.
  4. Re-store the updated JSON object with $.toJSON().

Hope this gets included in the project, great job so far.

-Jon Ursenbach

Attachment: addremove.diff

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=3

Detect & use of native browser JSON support (where available) urgently required

From marcusjt on July 06, 2009 03:42:38

FF 3.1+ and IE 8 now have native bidirectional JSON support - see http://blog.mozilla.com/webdev/2009/02/12/native-json-in-firefox-31/ for
details on using the FF implementation (which mirror's IE8's).

Such native support is likely to become ubiquitous shortly, but even so,
jquery-json will continue to be useful because there will still be older
versions of browsers out there, so if jquery-json detects and uses these
native features where available in newer browsers while continuing to
provide JSON conversion functionality for older browsers, then developers
can simply add the plugin and use JSON without needing to worry about
browser support.

I suspect that if jquery-json is NOT quickly updated to perform as above,
another plugin will spring up to do so, and jquery-json will cease to be
relevant.

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=19

Inherited properties should be left out

From krinklemail on September 18, 2011 04:52:37

If the object has an extended prototype object (which I think is a bad thing, but some people do it), there are values being put into the JSON string that shouldn't be included.

In some situations it's an option to not support these conditions, however in the case of this plugin we should replicate that browsers behavior.

Code to reproduce:
Object.prototype.foo = 'bar';
var obj = { test: 12 };
JSON.stringify( obj );

[String] {"test":12}
$.toJSON( obj );
[String] {"test":12,"foo":"bar"}

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=50

$.postJSON

From benjamin.schweizer on October 18, 2009 00:40:39

/*
 * Hello Brandley, tonight I've tried to figure out how to do proper
 * JSON POSTs using "Content-type: application/json" and serialized JSON
 * data in the content portion (body) of my HTTP requests. This is
 * specified in the Twitter API for status updates and Identica JSON
 * webservices (found via Mark Pilgrim).
 * After some tests, I had to recognize that jQuery does not support JSON
 * encoding in the core distribution and aside of $.getJSON(), there
 * is no $.postJSON().
 * Below is an proposed update. As it relies on your json plugin, I'd ask
 * you to add it to your code base so that other jQuery users can benefit
 * of it.
 */

$.postJSON = function(url, data, callback) {
    return jQuery.ajax({
        'type': 'POST',
        'url': url,
        'contentType': 'application/json',
        'data': $.toJSON(data),
        'dataType': 'json',
        'success': callback
    });
};

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=28

toJSON fails with property of value JSON array of nested objects.

From joseph.conder on September 03, 2009 20:06:29

What steps will reproduce the problem? 1. var objJSON{}; objJSON.domain = 'somedomain identity'; objJSON.groups = [ some array of
JSON Objects ];
2.alert(jQuery.toJSON(objJSON));

What is the expected output?
{"domain":"duke.edu","groups":[{"domain": "duke.edu", "users": [{"uid": "conder"},
{"uid": "jamesc"}, {"uid": "kldavis"}, {"uid": "goldberg"}, {"uid": "kku"}, {"uid":
"gowang"}], "uid": "CEBE Technology", "name": "CEBE Technology"}]}

What do you see instead?
{"domain":"duke.edu","groups":"[{"domain": "duke.edu", "users": [{"uid": "conder"},
{"uid": "jamesc"}, {"uid": "kldavis"}, {"uid": "goldberg"}, {"uid": "kku"}, {"uid":
"gowang"}], "uid": "CEBE Technology", "name": "CEBE Technology"}]"} What version of the product are you using? On what operating system? 2.2, Mac OS X (10.4.11) Please provide any additional information below. Trying to post this JSON object to a URL using jQuery.ajax .. I can do this fine using Prototype
($H(objJSON).toJSON())... but can't find a jQuery solution that works.

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=25

Date.prototype.toJSON output not quoted, missing hour/minute/seconds

From mfkahn on June 23, 2009 15:28:24

The stringified output of a javascript Date is not quoted, and lacks
hours/minutes/seconds. The following modification will make the function
compatible with prototype's toJSON() extension on Date objects, and will
allow the JSON produced to be deserialized properly by PHP's json_decode()
function (so long as a fix identified in another issue that strips
undefined's from the serialized JSON data is also present).

Current code:

Date.prototype.toJSON = function(date)
// Yes, it polutes the Date namespace, but we'll allow it here, as
// it's damned usefull.
{
    return this.getUTCFullYear()   + '-' +
         toIntegersAtLease(this.getUTCMonth()) + '-' +
         toIntegersAtLease(this.getUTCDate());
};

Compatible with prototype, PHP's json_decode:

Date.prototype.toJSON = function() {
    return '"' + this.getUTCFullYear() + '-' +
    toIntegersAtLeast(this.getUTCMonth() + 1) + '-' +
    toIntegersAtLeast(this.getUTCDate()) + 'T' +
    toIntegersAtLeast(this.getUTCHours()) + ':' +
    toIntegersAtLeast(this.getUTCMinutes()) + ':' +
    toIntegersAtLeast(this.getUTCSeconds()) + 'Z"';
};

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=17

JSON output gets escaped twice if Prototype.js is present

From matti.jagula on March 18, 2010 14:44:53

What steps will reproduce the problem? 1. Include jquery, cometd, jquery.json-2.2.js and jquery.comet libraries on
a page
2. Include prototype 1.6 on the same page
3. call $.cometd.handshake();
4. The comet server receives doubly-escaped JSON string What is the expected output? What do you see instead? The expected behaviour would result in a successful handshake being
performed with comet server. What version of the product are you using? On what operating system? Version 2.2 on Windows Vista with Firefox/Chrome/IE Please provide any additional information below. It appears that if object.toJSON is present on an object, jquery.json calls
toJSON twice for that object, as evidenced on the following line:

if (typeof o.toJSON == "function")
return $.toJSON( o.toJSON() );

I believe this should read like the following:

if (typeof o.toJSON == "function")
return o.toJSON();

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=35

jquery-json .toJSON puts a not-needed space behind ":"

From haraldarminmassa on July 23, 2008 13:35:40

dat={"haus":123,"Berg":"lajsdasd"};
serializeJSON(dat) // Bob Ippolito from mochikit

-> output:#
"{"haus":123, "Berg":"lajsdasd"}"

$j.toJSON(dat) // jQuery JSON Plugin
"{"haus": 123, "Berg": "lajsdasd"}"

Fix for this:
change line 123 of jquery.json.js
from

ret.push(name + ": " + val);

to

ret.push(name + ":" + val);

every byte counts :)

patch hereby submitted to PublicDomain, Harald

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=1

Intellisense for Visual Studio 2008

From jameswillockuk on December 15, 2008 15:18:31

I've just picked up your plug-in so thanks for that. In the .Net world
Visual Studio 2008 now supports intellisense/auto-complete for javascript
provided you provide further a design time instance of your .js source file

  • with the extension *-vsdoc.js - which has been commented accordingly. So
    in this instance an extra file is required; jquery.json-1.3-vsdoc. I've
    quickly knocked this up and am successfully using it should you wish to
    include it in your repository and make it available for others.

The file is attached. Please give me a shout if you have any questions.

Regards,

James

Attachment: jquery.json-1.3-vsdoc.js

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=9

Plugin don't work

From enfix86 on April 08, 2010 22:39:10

need to pass a JSON object from $.post() jQuery function to PHP page.
I tried this plugin jquery-json, but don't work:

//include jquery.js and jquery.json.js

$(document).ready(function(){
var data = new Object();
data.hello = "Hello";
data.world = "World";
var datajson = $.toJSON(data);
$.post('file.php', {data: datajson}, function(res){
alert(res);
});
});

And file.php has this simple line:

What's the problem ?

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=38

error eval-ing undefined string

From todd.chambery on May 13, 2010 12:50:02

I'm getting an "Invalid something or other" when passing an undefined value
to $.evalJSON (line 117). What steps will reproduce the problem? 1. Pass an undefined value to $.evalJSON What is the expected output? What do you see instead? Should return null(?). What version of the product are you using? On what operating system? 2.3 Please provide any additional information below. Wrapping in a test fixed the error for me:

$.evalJSON = function(src)
{
    if(src) {
        if (typeof(JSON) == 'object' && JSON.parse)
            return JSON.parse(src);
        return eval("(" + src + ")");
    }
};

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=39

Values for checkbox or multiselect groups should also be an array if there is only one value

From recoco.zhang on March 11, 2010 02:28:40

What steps will reproduce the problem? 1. submit a form including checkbox or multiple select, in the example: http://tobiascohen.com/files/stackoverflow/jquery-form-serializeObject.html the favorite food field
2.if choose two options of favorite food field, it will generate the JSON
correctly.
JSON data will be "food[]": ["Steak", "Pizza"].
but if only choose one option, it will only get a string without the array
start and end token that are [ and ]. The JSON data will be "food[]": "Steak".
3.So the problem will arise. Such as in Spring data bonding, the favorite
food field will be bonded to String other then String[] because of missing
the array start and end token if you only choose one option. If choosing
more than options, it will work correctly. What is the expected output? What do you see instead? expected output : "food[]": ["Steak"]
indeed output : "food[]": "Steak" What version of the product are you using? On what operating system? 2.2, linux Please provide any additional information below. I think it's a bug. I think that if handling checkbox or multiple select ,
jquery-json should treat them as array.

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=34

Evaluate functions before parsing in $.toJSON

From spcghst440 on March 30, 2010 18:50:42

Is there a way that a function could be evaluated with the $.toJSON or a
possible overload? I have need of using functions in a object that I would
like evaluated when it gets converted. EX:

var thing = {
plugin: 'jquery-json',
version: 2.2,
customdata: function() { return "foo"; }
};

var encoded = $.toJSON(thing);
document.writeln(encoded);

Returns {"plugin":"jquery-json","version":2.2} when I would like to return:

{"plugin":"jquery-json","version":2.2, "customdata": "foo"}

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=37

Error on the toJSON function

From walter.poch on September 09, 2008 17:47:36

What steps will reproduce the problem? var data = {date: new Date()};
var json = jQuery.toJSON(data); What is the expected output? What do you see instead? EXPECTED:
{ "date": 2008-09-09}
NOW:
[Break on this error] return date.getUTCFullYear() + '-' +
date has no properties
(no name)(undefined)jquery.json-1.1.j... (line 28)
toJSON(Tue Sep 09 2008 12:42:34 GMT-0300, undefined)jquery.json-1.1.j...
(line 85)
toJSON(Object, undefined) What version of the product are you using? On what operating system? jquery.json-1.1.js - Windows XP, FireFox 2.0 Please provide any additional information below. To fix this in dates (since is the only which extends a JS core Object)
Replace at line 85:
return o.toJSON(compact);
with this
return o.toJSON(o);

Regards!

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=2

toJSON fails for associative array

From [email protected] on March 22, 2010 14:28:25

What steps will reproduce the problem? var myArray = new Array();
myArray["index"] = 23;
myArray["recipient"] = "joe";
myArray["body"] = "test body";

alert($.toJSON(myArray)); What is the expected output? What do you see instead? Expected:
[{index: "23", recipient: "joe", body: "test body"}]

Actual Result:
[] What version of the product are you using? On what operating system? json-2.2.min.js on Ubuntu Karmic Please provide any additional information below.

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=36

Object members with value of type "undefined" should be removed

From mcknut on September 29, 2009 14:12:02

What steps will reproduce the problem? 1. var a = {foo:undefined}
2. $.toJSON(a) 3. What is the expected output? What do you see instead? Expected: {"foo":null}
See this instead: {"foo":undefined} What version of the product are you using? On what operating system? 2.2 Please provide any additional information below. The JSON spec here shows that undefined is not valid, it should be null: http://json.org/ Fix is pretty simple so I haven't attached a patch.

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=27

Element array with undefined value is not converted to json

From mkurshin on July 31, 2009 08:02:27

Well guys, I have bad English, so the description of the problem as I can.
I have an array that contains the numerical values: arr = new Array
(111,222,333,444,555)
substance as follows:
When I remove the first 2 array:
delete arr [0];
delete arr [1];
it takes an array of this type:
arr [0] == undefined,
arr [1] == undefined,
arr [2] == 333,
arr [3] == 444,
arr [4] == 555

continue with the conversion of the array arr in json format is now a string:
[undefined, undefined, "333", "444", "555"]
but to convert back (json to Array) do not go!

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=22

IE8 JSON.stringify gives 'null' instead of '""' for document.createElement("input").value

From l.giraudel on November 23, 2010 16:37:46

There is a bug in the JSON.stringify() method of some versions of IE8 : cf http://blogs.msdn.com/b/jscript/archive/2009/06/23/serializing-the-value-of-empty-dom-elements-using-native-json-in-ie8.aspx The following assertion is supposed to be true :
JSON.stringify(document.createElement("input").value)==='""'

But in some IE8 versions this assertion is false because JSON.stringify(document.createElement("input").value) returns '"null"'.

I found this bug in in IE8 on Windows Server 2008 but I don't have the bug on Windows 7.

I edited my jquery.json.js file :

(function($){
    $.toJSON = function(o) {
        if (typeof(JSON) == 'object' && JSON.stringify) {
            if ($.browser.msie && $.browser.version == "8.0" && JSON.stringify(document.createElement("input").value)==='"null"') {
                return JSON.stringify(o, function(k, v) { return v === "" ? "" : v; });
            } else {
                return JSON.stringify(o);
            }
        }

        var type = typeof(o);
        [...]

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=44

$.evalJSON should throw SyntaxError on single quotes (just like native JSON.parse)

From [email protected] on December 01, 2009 16:55:05

  1. Pass a string to evalJSON that has a single quote in Safari
  2. A SyntaxError occurs.

I got this error after upgrading from a previous version of the plugin. I have no problem
eliminating single quotes from my json strings but I didn't know I had to. To help others, I suggest
addressing the issue. There are options like:

  1. Make a note in the documentation that says not to include single quotes in the src parameter.
  2. Check for single quotes in the src variable and throw an error that indicates invalid input
  3. Replace single quotes with double quotes
  4. Put a try/catch around JSON.Parse. In the catch check for single quote and throw an error
    indicating the problem. This avoids overhead with (2).

There are other options, but the point is the issue should be addressed. I don't think people should
be expected to know that single quotes can't be used in these functions.

I love the plugin and use it all the time. Great work!

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=30

Treat Arguments object as an array

From lubomir1971 on September 16, 2009 22:21:23

Hello!

Thanks for plugin!

First - seems error version typed in source and download page - in source
2.1 but on page - 2.2

Second in version 2.1 (2.2?):

I get empty {} object when use plugin in such style:

myfunction = function() {

console.debug(arguments); // in console - ["asdasd", 12, 13212]
console.debug( $.toJSON( arguments ) ); // in console - {}

}

Plese, fix it. Thanks!

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=26

JSON is not defined

From xefris on August 19, 2009 17:17:32

I got the following error using Firebug on Firefox 3.0.13 on WinXP

  • JSON is not defined
  • {if(JSON&&JSON.stringify)\n

I changed these 2 lines on the minified version to fix this problem.
From,
3: {if(JSON&&JSON.stringify)
22: {if(JSON&&JSON.parse)

To,
3: {if(typeof JSON!='undefined'&&JSON&&JSON.stringify)
22: {if(typeof JSON!='undefined'&&JSON&&JSON.parse)

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=24

date.toJSON() gets wrong month

From stephan.veigl on January 08, 2009 16:09:23

What steps will reproduce the problem? 1. call toJSON() for any Date object What is the expected output? What do you see instead? The month of the output is 0 based instead of 1 based like you would expect
in a normal date string.
So the date: 1990-1-1 becomes 1990-0-1. Please provide any additional information below. There are two additional points:

  1. The JavaScript Date object is more of an DateTime object than just a
    pure date.
  2. IMHO it doesn’t make sense to use UTC time if you don’t supply the time
    offset as well.

fix:
Date.prototype.toJSON = function(date)
{
return this.getFullYear() + '-' +
toIntegersAtLease(this.getMonth()+1) + '-' +
toIntegersAtLease(this.getDate()) + ' '+
toIntegersAtLease(this.getHours()) + ':'+
toIntegersAtLease(this.getMinutes()) + ':'+
toIntegersAtLease(this.getSeconds());
};

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=10

Don't escape non-latin UTF-8 characters in IE8 JSON.stringify

From [email protected] on November 15, 2010 11:25:43

IE8 stringify make \uXXXX escaped sequences for non-latin charracter, but all other browsers return raw UTF-8 data.

  1. var sys = require('sys');
    var struct = ['вася'];
    var json_string = JSON.stringify(struct);
    sys.debug(json_string);

It returns "DEBUG: ["\u0432\u0430\u0441\u044f"]" and I want "DEBUG:["вася"]". What version of the product are you using? On what operating system? jquery-json 2.2, IE8, Windows 7 x64. Please provide any additional information below. Fix it by replace
return JSON.stringify(o);
by
return unescape(JSON.stringify(o).replace(/\u/g, '%u'));

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=43

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.