开发者

How to implement a simple JSON parser in c++ (can't use external libs)

One of my clients wants to implement a JSON parser and reader in c++. He doesn't want to adopt a third-party library. So I would like to know where I can fi开发者_如何学运维nd a simple implementation of a JSON parser so I could adjust it or implement it in c++


Parsing JSON is a Minefield. There are lot of different Json parsers with lot of different errors. The a summary table of errors with a list of parsers can be found here When I wrote my Json parser, there were two tricky points: Unicode support and correct support for floating point numbers. Par example, the Json specification does not limit the precision of numbers, so the following number is correct: 112345678911234567891123456789.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000123 but it cannot be converted into double float number without loss of precision. Therefore, if you are writing your own parser, you should first discuss the limitations of the parser and the results of its work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜