Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!82.197.223.103.MISMATCH!feeder3.cambriumusenet.nl!feed.tweaknews.nl!193.141.40.65.MISMATCH!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="ISO-8859-1" Message-ID: <2746027.qYQeW1xAia@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Sat, 10 Nov 2012 10:21:45 +0100 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 7Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. <2261899.gBobAo4G4S@PointedEars.de> Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 33 NNTP-Posting-Date: 10 Nov 2012 10:21:46 CET NNTP-Posting-Host: e8c8ef67.newsspool2.arcor-online.net X-Trace: DXC=bf?[YjCKb2UI?44J>Z[:RQA9EHlD;3YcR4Fo<]lROoRQ8kFKPM=DB64g7VTP4AI\omSTE9T X-Complaints-To: usenet-abuse@arcor.de Xref: csiph.com comp.lang.javascript:17113 Cezary Tomczyk wrote: > As for parsing JSON string and according to what wrote Asen. Quick > review of David Mark code bring me [1]: > > [...] > return function(s) { return (new Function('return (' + s + ')'))(); }; > [...] > > On the other hand, looked into the code > https://github.com/douglascrockford/JSON-js/blob/master/json2.js [2] and > I see much, much more complicated regexps and rest of code to check JSON > string before its evaluated. > > Now I am more confused than before. Why code [1] is so simple and code > [2] is so complicated? One executes ECMAScript-conforming code. The other evaluates *data* that needs to be parsed according to JSON, which is a *subset* of ES syntax, instead. Until there were implementations of ES 5 there was no built-in JSON parser/serializer, and for some other programming languages there still is not. So people (starting with Douglas Crockford, who devised JSON) wrote and are writing libraries to support it. PointedEars -- Use any version of Microsoft Frontpage to create your site. (This won't prevent people from viewing your source, but no one will want to steal it.) -- from (404-comp.)