Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
290 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 Answer

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解析器。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...