C语言有效json校验

Valid json check in C language

我在 Google 中搜索了很多。我想以编程方式检查下面的字符串在 C 中是否有效 JSON。我该怎么做? (我目前正在使用 json-c 库。)

        char * string = "{
                      number1 : 100,
                    number2 : 10,
                    files : [ c , c++, java,PHP,java,PHP ],
                    random: [123567876523333,908,988]
                    }";

库没有检查字符串是否有效的函数JSON。

你可以使用json_tokener_parse(const char *str)函数,如果解析失败returnsNULL

详情见here