You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
/ * - - -
{
"knownissue" : "JSON.stringify() can be given a property list to serialize; duplicates should be eliminated but Duktape (and other engines) will happily serialize a property multiple times"
}
-- - * /
/ * = = =
{ "bar" : 2 , "foo" : 1 , "baz" : 4 , "quux" : 3 }
{ "bar" : 2 , "1" : 5 , "foo" : 1 }
=== * /
/ * E 5 . 1 S e c t i o n 1 5 . 1 2 . 1 3 , m a i n a l g o r i t h m , s t e p 4 . b . i i . 5 r e q u i r e s t h a t a n
* implementation detect duplicates in the property list and refuse to
* serialize the same property name twice .
*
* Note : both V8 and Rhino fail this test ( but in different ways ) .
* /
function dupTest1 ( ) {
var obj = { foo : 1 , bar : 2 , quux : 3 , baz : 4 } ;
print ( JSON . stringify ( obj , [ 'bar' , 'foo' , 'baz' , 'baz' , 'baz' , 'quux' ] ) ) ;
}
function dupTest2 ( ) {
var obj = { foo : 1 , bar : 2 , quux : 3 , baz : 4 , "1" : 5 } ;
// dup check happens after coercion
print ( JSON . stringify ( obj , [ 'bar' , 1 , new Number ( 1 ) , '1' , 'foo' ] ) ) ;
}
try {
dupTest1 ( ) ;
dupTest2 ( ) ;
} catch ( e ) {
print ( e ) ;
}