以下函数将查找全部user.id整数:
- void simdjson_traverse(std::vector<int64_t> &answer, ParsedJson::iterator &i) {
- switch (i.get_type()) {
- case '{':
- if (i.down()) {
- do {
- bool founduser = equals(i.get_string(), "user");
- i.next(); // move to value
- if (i.is_object()) {
- if (founduser && i.move_to_key("id")) {
- if (i.is_integer()) {
- answer.push_back(i.get_integer());
- }
- i.up();
- }
- simdjson_traverse(answer, i);
- } else if (i.is_array()) {
- simdjson_traverse(answer, i);
- }
- } while (i.next());
- i.up();
- }
- break;
- case '[':
- if (i.down()) {
- do {
- if (i.is_object_or_array()) {
- simdjson_traverse(answer, i);
- }
- } while (i.next());
- i.up();
- }
- break;
- case 'l':
- case 'd':
- case 'n':
- case 't':
- case 'f':
- default:
- break;
- }
- }
深入较量
假如您想相识各类理会器怎样验证给定的JSON文件:
- make allparserscheckfile
- ./allparserscheckfile myfile.json
对付机能较量:
- make parsingcompetition
- ./parsingcompetition myfile.json
举办更普及的较量:
- make allparsingcompetition
- ./allparsingcompetition myfile.json
【编辑保举】 - SAP 开源 SCA 器材,扫描软件包依靠裂痕
- Gartner陈诉:正处于数据科学与呆板进修器材 “大爆炸”的期间
- 可视化及时Web日记说明器材,堪称神器!
- 超 100000 个 GitHub 代码库泄漏了 API 或加密密钥
- 怎样阅读一份源代码?
【责任编辑:张燕妮 TEL:(010)68476606】
点赞 0 (编辑:湖南网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|