简体   繁体   English

JSON.parse用什么编写/它是开源的吗?

[英]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. PHP函数是用C编写的,您可以根据需要查看源代码。 For example here - session_start source 例如此处-session_start源

What about with Javascript? Java脚本呢? How are functions like JSON.parse implemented? JSON.parse之类的函数如何实现? Where can I go to view the source? 我在哪里可以查看源代码?

Thanks! 谢谢!

JSON.parse is native. JSON.parse是本机的。 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 v8(Chrome)对于JsonParser::ParseJson具有C ++方法

spidermonkey (Firefox) has a C++ function for js_json_parse 的SpiderMonkey(火狐)具有用于C ++函数js_json_parse

JavaScriptCore (Webkit / Safari) has a C++ function for JSONProtoFuncParse JavaScriptCore(Webkit / Safari)具有JSONProtoFuncParse的C ++函数

Rhino (Mozilla) has a Java method for parseValue Rhino(Mozilla)具有用于parseValue的Java方法

the Opera and IE implementations are closed source. Opera和IE实现是封闭源代码。 I also think Nitro's implementation is closed source aswell. 我也认为Nitro的实现也是封闭源代码。

Note there are many other JavaScript engines. 请注意,还有许多其他JavaScript引擎。

Each JavaScript engine that supports it will have its own implementation of JSON.parse . 每个支持它的JavaScript引擎都有其自己的JSON.parse实现。 You can view the code of the various open source engines ( V8 , SpiderMonkey ) in their respective repositories. 您可以在各自的存储库中查看各种开源引擎( V8SpiderMonkey )的代码。 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; 您还可以在Crockford的github页面上查看JavaScript实现(Crockford是提出JSON的人 )–实际上,不止一个; 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). 有一个版本是状态机,另一个是递归下降解析器,而另一个则依赖于eval (有点作弊)。 There are also various implementations in various languages linked from the JSON home page . JSON主页链接的语言也有多种实现。

It depends on the browser. 这取决于浏览器。 You view the source of your favorite and see if you can find it there. 您查看喜欢的来源,然后查看是否可以在其中找到它。

Depends on the browser. 取决于浏览器。

For example: Chrome is using the V8 javascript engine. 例如:Chrome使用的是V8 JavaScript引擎。 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 . http://code.google.com/p/v8/ (可能包含在其内部),也可能是Chromium项目http://www.chromium.org/Home的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM