-
When the end element of JsonObject and JsonArray is a number, an error occurs if the number is one of the outermost values.
I.e., it only works if the ending is two or more ']' (or '}').
I guess the problem may be caused by the readNumber() method in Lexer.java. -
According to the above bug, it can be inferred that the parser can not analyze whether the number of ']'(or '{') at the end matches with '['(or '{'), as long as it is greater than or equal to the number of '[', it can pass the test.
I think introducing a 'count' variable would solve this problem.
自己动手实现一个简单的JSON解析器
如何编写一个JSON解析器
JSON
Compilers 南京大学软件学院 编译原理 课程视频