Editing json parsing and stringifying This edit will create a new revision. Your details (optional) Name Email (won’t be displayed; might be used for Gravatar) URL Test case details Title * Published (uncheck if you want to fiddle around before making the page public) Description (in case you feel further explanation is needed)(Markdown syntax is allowed) Are you a spammer? (just answer the question) Preparation code Preparation code HTML (this will be inserted in the <body> of a valid HTML5 document in standards mode) (useful when testing DOM operations or including libraries) Include JavaScript libraries as follows: <script src="//cdn.ext/library.js"></script> Define setup for all tests (variables, functions, arrays or other objects that will be used in the tests) (runs before each clocked test loop, outside of the timed code region) (e.g. define local test variables, reset global variables, clear canvas, etc.) (see FAQ) var isValid = function(s) { // All empty whitespace is not valid. if (/^\s*$/.test(s)) { return false; } // Don't make these static since they have the global flag. var backslashesRe = /\\["\\\/bfnrtu]/g; var simpleValuesRe = /"[^"\\\n\r\u2028\u2029\x00-\x08\x0a-\x1f]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g; var openBracketsRe = /(?:^|:|,)(?:[\s\u2028\u2029]*\[)+/g; var remainderRe = /^[\],:{}\s\u2028\u2029]*$/; return remainderRe.test(s.replace(backslashesRe, '@'). replace(simpleValuesRe, ']'). replace(openBracketsRe, '')); }; var json = JSON.stringify({key: Math.random(), isError: false , data: ["116910304844117268718",[,,"https://plus.FooBar.com/116910304844117268718","//lh4.FooBarusercontent.com/-tQJAx2-8rqE/AAAAAAAAAAI/AAAAAAAATH4/67EZ6xAu1Z0/photo.jpg",[[,,,,[] ,6] ,"Foo","Bar","Foo Bar",0] ,[[,,,,[] ,6] ,[["twitter"] ] ] ,[[,,,,[] ,6] ,"engineer"] ,[[,,,,[] ,6] ,[["FooBar","engineer",[[1,1,2010] ,[1,1,2012] ,1] ,""] ,["JSConf","",[[1,1,2010] ,[1,1,2012] ] ,""] ,["S2","Technical Director",[[1,1,2008] ,[1,1,2010] ] ,""] ,["ITC","engineer",[[1,1,2004] ,[1,1,2008] ] ,""] ,["Yo","CEO",[[1,1,2007] ,[1,1,2008] ] ,""] ] ] ,[[,,,,[] ,6] ,[["NUniversity","",[] ,""] ] ] ,[[,,,,[] ,6] ,"San Francisco",["Hamburg","Elmshorn","Abc, SD"] ,,["San Francisco",[,377749300,-1224194160,1] ] ,[["Hamburg",[,535538150,99915750,1] ] ,["Elmshorn",[,537552990,96562390,1] ] ,["Abc, SD",[,443683160,-1003509660,1] ] ] ] ,"//maps-api-ssl.FooBar.com/maps/api/staticmap?size\u003d195x150\u0026sensor\u003dfalse\u0026client\u003dFooBar-profiles\u0026language\u003den\u0026markers\u003dsize:small%7Ccolor:green%7C53.553815,9.991575%7C53.755299,9.656239%7C44.368316,-100.350966\u0026markers\u003dsize:small%7Ccolor:blue%7C37.77493,-122.419416\u0026signature\u003dYuGUlNbxvxoG5OXqnMKhkQgfRCw%3D",[[] ,[,,,,[] ,6] ,[,,,,[] ,6] ] ,[[,,,,[] ,6] ,["1-650-390-3497"] ,[] ,[] ,[] ,,["3338 17th St. Apt 207, 94110 San Francisco, CA, USA"] ,[] ,,[["Foo.Bar@gmail.com",1] ] ,[[,"3338 17th St. Apt 207, 94110 San Francisco, CA, USA"] ] ] ,[[,,,,[] ,6] ,[] ,[] ,[] ,[] ,,[] ,[] ,,[] ,[] ] ,[[,,,,[] ,6] ,"Asynchronous Identity Disorder\u003cbr\u003e\u003cdiv\u003e\u003cspan style\u003d\"font-style:italic\"\u003eOpinions expressed here are my own, yadda, yadda.\u003c/span\u003e\u003c/div\u003e"] ,,[[,,,,[] ,6] ,"October 27",0,27,10] ,[[,,,,[] ,6] ,1] ,,[[,,,,[] ,6] ,""] ,,,[[,,,,[] ,6] ,5,0] ,[[,,,,[] ,6] ,[] ] ,[[,,,,[] ,6] ,0] ,[[,,,,[] ,6] ,0] ,[[,,,,[] ,6] ,1] ,,,,"116910304844117268718",1,,[[,,,,[] ,6] ,"Curing my asynchronous identity disorder at FooBar"] ,,[[,,,,[] ,6] ,[] ] ,,[[,,,,[] ,6] ,0] ,,,0,,,,[0,1,1,,1,1,,,1] ,1,[4,,0,0,0,[] ,,,0] ,[[,,,,[] ,6] ,"twitter"] ,1,,1,[[[[,,,,[] ,6] ,"http://www.nonblocking.io/","//s2.FooBarusercontent.com/s2/favicons?domain\u003dwww.nonblocking.io\u0026alt\u003dp","NonBlocking.io","me",0,["http://www.nonblocking.io/"] ,[] ] ,[[,,,,[] ,6] ,"http://twitter.com/twitter","//s2.FooBarusercontent.com/s2/favicons?domain\u003dtwitter.com\u0026alt\u003dp","Twitter","me",0,["http://twitter.com/twitter","sgn://twitter.com/?ident\u003dtwitter"] ,[] ] ,[[,,,,[] ,6] ,"http://www.quora.com/Foo-Bar","//s2.FooBarusercontent.com/s2/favicons?domain\u003dwww.quora.com\u0026alt\u003dp","Foo-Bar","me",0,["sgn://quora.com/?ident\u003dFoo-Bar","http://www.quora.com/Foo-Bar"] ,[] ] ,[[,,,,[] ,6] ,"http://www.linkedin.com/in/FooBar","//s2.FooBarusercontent.com/s2/favicons?domain\u003dwww.linkedin.com\u0026alt\u003dp","LinkedIn","me",0,["sgn://linkedin.com/?ident\u003dFooBar","http://www.linkedin.com/in/FooBar"] ,[] ] ,[[,,,,[] ,6] ,"https://github.com/twitter","//s2.FooBarusercontent.com/s2/favicons?domain\u003dgithub.com\u0026alt\u003dp","GitHub","me",0,["sgn://github.com/?ident\u003dtwitter","https://github.com/twitter"] ,[] ] ,[[,,,,[] ,6] ,"http://www.youtube.com/user/Foo1234123","//s2.FooBarusercontent.com/s2/favicons?domain\u003dwww.youtube.com\u0026alt\u003dp","Foo Bar","me",1,["sgn://youtube.com/?ident\u003dFoo1234123","http://www.youtube.com/user/Foo1234123"] ,[[2] ,[2] ] ] ] ,,[,,,,[] ,6] ] ,[[[[,,,,[] ,6] ,"http://www.JSConf.eu","//s2.FooBarusercontent.com/s2/favicons?domain\u003dwww.JSConf.eu\u0026alt\u003dp","JSConf EU","contributor-to",0,["http://www.JSConf.eu"] ,[] ] ,[[,,,,[] ,6] ,"http://jsconf.com/","//s2.FooBarusercontent.com/s2/favicons?domain\u003djsconf.com\u0026alt\u003dp","JSConf","contributor-to",0,["http://jsconf.com/"] ,[] ] ] ,,[,,,,[] ,6] ] ,[[[[,,,,[] ,6] ,"http://code.FooBar.com/p/joose-js/","//s2.FooBarusercontent.com/s2/favicons?domain\u003dcode.FooBar.com\u0026alt\u003dp","Joose - JavaScript Meta Object System","",0,["http://code.FooBar.com/p/joose-js/"] ,[] ] ,[[,,,,[] ,6] ,"http://blok.appspot.com/","//s2.FooBarusercontent.com/s2/favicons?domain\u003dblok.appspot.com\u0026alt\u003dp","blok.appspot.com","",0,["http://blok.appspot.com/"] ,[] ] ] ,,[,,,,[] ,6] ] ,1,,[[,,,,[] ,6] ,0] ,,,,,[[,,,,[] ,6] ,0] ,0,[2,[] ,["5819372865906803970",[0,0] ,1,,0] ] ,1,,[4,0] ,,,[[[,1,10000] ] ] ,,,,,[[1] ] ,"",[[,,,,[] ,6] ,""] ] ,"Foo.Bar@gmail.com",,"en",,,,,1,,1,,1,1,,,,,,"Foo Bar \u003cFoo.Bar@gmail.com\u003e",,,,1,,,1,2,,1,,,"WmgS6js9vMOsD1wK/ASOvW5_gecqmcBqZf",[4,0] ,0] }); Define teardown for all tests (runs after each clocked test loop, outside of the timed code region) (see FAQ) Code snippets to compare Test 1 Title Async (check if this is an asynchronous test) Code JSON.parse(json) Test 2 Title Async (check if this is an asynchronous test) Code eval('(' + json + ')') Test 3 Title Async (check if this is an asynchronous test) Code isValid(json); eval('(' + json + ')')