value-symbol.js (756B)
1 // Copyright (C) 2019 Aleksey Shvayka. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-serializejsonproperty 5 description: > 6 Symbol primitives are ignored, both as keys and as values. 7 info: | 8 JSON.stringify ( value [ , replacer [ , space ] ] ) 9 10 [...] 11 12. Return ? SerializeJSONProperty(the empty String, wrapper). 12 13 SerializeJSONProperty ( key, holder ) 14 15 [...] 16 11. Return undefined. 17 features: [Symbol] 18 ---*/ 19 20 var sym = Symbol('desc'); 21 assert.sameValue(JSON.stringify(sym), undefined); 22 assert.sameValue(JSON.stringify([sym]), '[null]'); 23 assert.sameValue(JSON.stringify({key: sym}), '{}'); 24 25 var obj = {}; 26 obj[sym] = 1; 27 assert.sameValue(JSON.stringify(obj), '{}'); 28 29 reportCompare(0, 0);