Skip to content Skip to sidebar Skip to footer

What Is Json.parse Written In / Is It Open Source?

PHP funcitons are written in C and you can look at the source code if you like. For example here - session_start source What about with Javascript? How are functions like JSON.p

Solution 1:

JSON.parse is native. That means it's defined in the browser, the implementation of the method is browser implementation specific.

v8 (Chrome) has a C++ method for JsonParser::ParseJson

spidermonkey (Firefox) has a C++ function for js_json_parse

JavaScriptCore (Webkit / Safari) has a C++ function for JSONProtoFuncParse

Rhino (Mozilla) has a Java method for parseValue

the Opera and IE implementations are closed source. I also think Nitro's implementation is closed source aswell.

Note there are many other JavaScript engines.

Solution 2:

Each JavaScript engine that supports it will have its own implementation of JSON.parse. You can view the code of the various open source engines (V8, SpiderMonkey) in their respective repositories. You can also view a JavaScript implementation on Crockford's github page (Crockford being the person who came up with JSON) — actually, more than one; there's a version that's a state machine, and another that's a recursive descent parser, and another that relies on eval (which is kind of cheating). There are also various implementations in various languages linked from the JSON home page.

Solution 3:

It depends on the browser. You view the source of your favorite and see if you can find it there.

Solution 4:

Depends on the browser.

For example: Chrome is using the V8 javascript engine. http://code.google.com/p/v8/ which may include that inside itself, or that could be a part of the Chromium project http://www.chromium.org/Home.

Post a Comment for "What Is Json.parse Written In / Is It Open Source?"