Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
292 views
in Technique[技术] by (71.8m points)

javascript - 如何使用Node.js解析JSON?(How to parse JSON using Node.js?)

How should I parse JSON using Node.js?

(我应该如何使用Node.js解析JSON?)

Is there some module which will validate and parse JSON securely?

(是否有一些模块可以安全地验证和解析JSON?)

  ask by Tikhon Jelvis translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can simply use JSON.parse .

(您可以简单地使用JSON.parse 。)

The definition of the JSON object is part of the ECMAScript 5 specification .

(JSON对象的定义是ECMAScript 5规范的一部分 。)

node.js is built on Google Chrome's V8 engine, which adheres to ECMA standard.

(node.js基于Google Chrome的V8引擎构建,该引擎遵循ECMA标准。)

Therefore, node.js also has a global object JSON [docs] .

(因此,node.js也具有全局对象JSON [docs] 。)

Note - JSON.parse can tie up the current thread because it is a synchronous method.

(注意JSON.parse可以占用当前线程,因为它是一种同步方法。)

So if you are planning to parse big JSON objects use a streaming json parser.

(因此,如果您打算解析大型JSON对象,请使用流式JSON解析器。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...