之前的rapidjson与protobuf对比:https://blog.csdn.net/robinfoxnan/article/details/118734387
按照官方说法,比rapidjson还要快,尤其是大文件;
优点是:使用.h与.c一对文件,不需要依赖第三方库;
代码地址:https://github.com/bulice/yyjson
解码接口比较简单容易理解:
void test1()
{
Timer timer;
timer.start();
const char *json = "{\"name\":\"Mash\",\"star\":4,\"hits\":[2,2,\"teststr\",3]}";
yyjson_doc *doc = yyjson_read(json, strlen(json), 0);
yyjson_val *root = yyjson_doc_get_root(doc);
double delta = timer.stop_delta_ms();
std::cout << delta << endl;
yyjson_val *name = yyjson_obj_get(root, "name");
printf("name: %s\n", yyjson_get_str(name));
yyjson_val *star = yyjson_obj_get(root, "star");
printf("star: %d\n", (int)yyjson_get_int(star));