ibireme / yyjson

The fastest JSON library in C
https://ibireme.github.io/yyjson/doc/doxygen/html/
MIT License
3.05k stars 262 forks source link

The trailing comma under the secondary object causes the json to not be parsed #67

Closed oopsrtos closed 2 years ago

oopsrtos commented 2 years ago

Describe the bug A clear and concise description of what the bug is. 二级对象下的逗号会导致json无法解析,虽然我知道这不符合json规范 {"objet":["ooject1":123,"ooject2":123,"ooject3":123,]}

Your environment

Additional context Add any other context about the problem here.

Clownsw commented 2 years ago

{"objets":[{"ooject1":123},{"ooject2":123},{"ooject3":123}]}

Clownsw commented 2 years ago

Describe the bug A clear and concise description of what the bug is. 二级对象下的逗号会导致json无法解析,虽然我知道这不符合json规范 {"objet":["ooject1":123,"ooject2":123,"ooject3":123,]}

Your environment

  • OS: [e.g. Ubuntu 20.04 x64]
  • Compiler: [e.g. gcc 9.3] centos7

Additional context Add any other context about the problem here.

这不是一个正确的JSON

ibireme commented 2 years ago

You could use the YYJSON_READ_ALLOW_TRAILING_COMMAS flag to accept trailing commas.

But in your case ["a":1,"b":2] is neither an object nor an array, so it will fail anyway.