Comments (3)
From krinklemail on November 13, 2012 17:41:23
Please provide a test case for the test suite (which would fail against the current code).
from jquery-json.
From dzlygin on May 19, 2013 05:34:04
var conf = new Array();
conf['key1'] = {text: 'sometext', posx: 50, posy: 50};
conf['key2'] = {text: 'othertext', posx: 50, posy: 80};
var a = $.toJSON(conf);
this code fails
from jquery-json.
This is not a valid bug for the native JSON.stringify
method exhibits the same behaviour and we're just polyfilling that. We can't take feature requests.
Per the ES5 specification, when serialising an Array object:
https://es5.github.io/#x15.12.3
For each value a property [that] has an array index property name. The properties are enumerated in the ascending array index order of their names.
The representation of arrays includes only the elements between zero and
array.length – 1
inclusive. Named properties are excluded from the stringification.
I recommend you do not be add named properties to array objects in your program. You're probably confusing arrays with objects (other programming languages sometimes call them arrays).
var conf = {};
conf.key1 = { text: 'sometext', posx: 50, posy: 50 };
conf.key2 = { text: 'othertext', posx: 50, posy: 80 };
var a = $.toJSON(conf);
// {"key1":{"text":"sometext","posx":50,"posy":50},"key2":{"text":"othertext","posx":50,"posy":80}}
from jquery-json.
Related Issues (20)
- Reference toJSON and evalJSON directly to the native API if available HOT 1
- Inherited properties should be left out HOT 3
- Guard against object with own property "hasOwnProperty" HOT 2
- JSON is not defined on IE 9 compatibility mode HOT 4
- String should not be double escaped HOT 4
- triggering parseJSON unnecessarily? HOT 2
- No tags in the source repository HOT 2
- Spelling errors in code comments HOT 1
- Adding support for loading HOT 1
- A simple example how to use jQuery-JSON HOT 2
- Array detection should not use .constructor (broken in IE9) HOT 3
- Constructed/Instantiated primitives should be stringified like their primitive equivalants. HOT 2
- Dummy issue HOT 1
- o.constructor === Array return fails with frames. HOT 1
- Serialize arrays with a toJSON method
- Different result in deferent page HOT 1
- Switch to UglifyJS for minification
- add bower.json file HOT 2
- Invalid procedure call or argument HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-json.