怎么实现一个 JSON Parser

2021-07-17 15:02:06 +08:00
 Turkestan
我看大多数人推荐的都是 Parsing Technique,这书 600 多页,我没有定力可以看完。。。
1441 次点击
所在节点    职场话题
7 条回复
micean
2021-07-17 15:30:09 +08:00
处理好对称的括号和引号就行了
Knuth
2021-07-17 16:16:27 +08:00
leptjson
一个简易的 json 实现库
aguesuka
2021-07-17 16:35:02 +08:00
Acebiu
2021-07-17 17:23:33 +08:00
> Lark is a parser - a program that accepts a grammar and text, and produces a structured tree that represents that text. In this tutorial we will write a JSON parser in Lark, and explore Lark's various features in the process.


https://github.com/lark-parser/lark/blob/master/docs/json_tutorial.md
ao99
2021-07-17 19:38:46 +08:00
agagega
2021-07-17 21:41:53 +08:00
这书虽然是神书,但不研究这块的是看不完的。有点类似你问算法看什么,让你去看 TAOCP.

https://www.json.org/json-en.html 已经给了形式化定义了,json 语法也不涉及左递归。所以只要懂一点点终结符 /非终结符的概念,就能写一个递归下降了。(其实不懂也可以写,懂递归就行)
yangzhezjgs
2021-07-18 10:33:51 +08:00
https://zhuanlan.zhihu.com/p/22457315 可参考叶老师的教程

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/790075

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX