Lines Matching full:stringify
226 // Stringify
228 assertEquals("true", JSON.stringify(true));
229 assertEquals("false", JSON.stringify(false));
230 assertEquals("null", JSON.stringify(null));
231 assertEquals("false", JSON.stringify({toJSON: function () { return false; }}));
232 assertEquals("4", JSON.stringify(4));
233 assertEquals('"foo"', JSON.stringify("foo"));
234 assertEquals("null", JSON.stringify(Infinity));
235 assertEquals("null", JSON.stringify(-Infinity));
236 assertEquals("null", JSON.stringify(NaN));
237 assertEquals("4", JSON.stringify(new Number(4)));
238 assertEquals('"bar"', JSON.stringify(new String("bar")));
240 assertEquals('"foo\\u0000bar"', JSON.stringify("foo\0bar"));
242 JSON.stringify("f\"o\'o\\b\ba\fr\nb\ra\tz"));
244 assertEquals("[1,2,3]", JSON.stringify([1, 2, 3]));
245 assertEquals("[\n 1,\n 2,\n 3\n]", JSON.stringify([1, 2, 3], null, 1));
246 assertEquals("[\n 1,\n 2,\n 3\n]", JSON.stringify([1, 2, 3], null, 2));
248 JSON.stringify([1, 2, 3], null, new Number(2)));
249 assertEquals("[\n^1,\n^2,\n^3\n]", JSON.stringify([1, 2, 3], null, "^"));
251 JSON.stringify([1, 2, 3], null, new String("^")));
253 JSON.stringify([1, 2, [3, [4], 5], 6, 7], null, 1));
254 assertEquals("[]", JSON.stringify([], null, 1));
256 JSON.stringify([1, 2, [3, [4], 5], 6, 7], null));
258 JSON.stringify([1, 2, [3, [4], 5], 6, 7], DoubleNumbers));
259 assertEquals('["a","ab","abc"]', JSON.stringify(["a","ab","abc"]));
263 assertThrows(function () { JSON.stringify(circular); }, TypeError);
267 assertEquals("[[],[],[]]", JSON.stringify(multiOccurrence));
269 assertEquals('{"x":5,"y":6}', JSON.stringify({x:5,y:6}));
270 assertEquals('{"x":5}', JSON.stringify({x:5,y:6}, ['x']));
272 JSON.stringify({a:"b",c:"d"}, null, 1));
273 assertEquals('{"y":6,"x":5}', JSON.stringify({x:5,y:6}, ['y', 'x']));
279 assertEquals('["10"]', JSON.stringify(array));
283 JSON.stringify({a:"b",c:"d"}, null,
288 JSON.stringify({a:"b",c:"d"}, null, 15));
292 assertEquals('{"x":"42"}', JSON.stringify({x: String}, newx));
293 assertEquals('{"x":42}', JSON.stringify({x: Number}, newx));
294 assertEquals('{"x":true}', JSON.stringify({x: Boolean}, newx));
296 assertEquals(undefined, JSON.stringify(undefined));
297 assertEquals(undefined, JSON.stringify(function () { }));
301 JSON.stringify([undefined,,function(){}]));
306 JSON.stringify({a: undefined, b: function(){}, c: 42, d: 42},
324 var encoded = JSON.stringify(string);
384 JSON.stringify([num37, numFoo, numTrue,
391 assertEquals('1', JSON.stringify(oddball));
400 assertEquals('{}', JSON.stringify(/regexp/));
401 assertEquals('42', JSON.stringify(counter));
412 assertEquals('"true"', JSON.stringify(oddball2));
418 assertEquals('"42"', JSON.stringify(falseNum));