## JSON parser for CMake
Module JSONParser.cmake contains macro `sbeParseJson` to parse JSON string stored in given variable (second argument).
Macro fills given variable (first argument) with list of all names in JSON string. For each name it creates variable and sets the value from JSON string.
To clear created variables use macro `sbeClearJson`.
> **Module does not validate given JSON string. If given JSON is malformed, the macro gives unpredictable result.**
### Example
JSON to parse:
``` json
{"menu": {
"header": "SVG Viewer",
"items": [
{"id": "Open"},
{"id": "OpenOld", "label": null },
{"id": "OpenNew", "label": "Open New"},
null,
{"id": "ZoomIn", "label": ["Zoom In", "Zoom At"] },
{"id": "ZoomOut",
"label":
{
"short": ["zo", "zout"],
"long":"Zoom Out"
}
},
{"id": "OriginalView", "label": "Original View"},
null
],
"elements" : ["one", "two", { "number":"three", "Desc": "Number" }, null ]
}}
```
Let assume that above JSON is stored in variable `jsonTest` in CMake script. It can be parsed with following lines of code.
``` cmake
include(JSONParser.cmake)
# name of variable not string itself is passed to macro sbeParseJson
sbeParseJson(example jsonTest)
# Now you can use parsed variables.
foreach(var ${example})
message("${var} = ${${var}}")
endforeach()
# when you want to access concrete JSON object, use the names in JSON, the array indexes for JSON object MUST be given after '_'
# e.g if you want to store value of object 'id' of first element of array 'items' in object 'menu'
set(FirstItemId ${example.menu.items_0.id})
# e.g if you want to store 1-th element of array 'short' in object 'label' of 5-th element of array items in object menu
set(ShortLabel ${example.menu.items_5.label.short_0})
# When you are done, clean parsed variables
sbeClearJson(example)
```
Macro `sbeParseJson` creates following variables and its values (`variable name` = `value`).
```
example.menu.header = SVG Viewer
example.menu.items = 0;1;2;3;4;5;6;7
example.menu.items_0.id = Open
example.menu.items_1.id = OpenOld
example.menu.items_1.label = null
example.menu.items_2.id = OpenNew
example.menu.items_2.label = Open New
example.menu.items_3 = null
example.menu.items_4.id = ZoomIn
example.menu.items_4.label = 0;1
example.menu.items_4.label_0 = Zoom In
example.menu.items_4.label_1 = Zoom At
example.menu.items_5.id = ZoomOut
example.menu.items_5.label.short = 0;1
example.menu.items_5.label.short_0 = zo
example.menu.items_5.label.short_1 = zout
example.menu.items_5.label.long = Zoom Out
example.menu.items_6.id = OriginalView
example.menu.items_6.label = Original View
example.menu.items_7 = null
example.menu.elements = 0;1;2;3
example.menu.elements_0 = one
example.menu.elements_1 = two
example.menu.elements_2.number = three
example.menu.elements_2.Desc = Number
example.menu.elements_3 = null
```
没有合适的资源?快使用搜索试试~ 我知道了~
PyPI 官网下载 | couchbase-3.0.4.tar.gz
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 56 浏览量
2022-01-10
04:35:38
上传
评论
收藏 6.38MB GZ 举报
温馨提示
共206个文件
py:125个
c:30个
rst:21个
资源来自pypi官网。 资源全名:couchbase-3.0.4.tar.gz
资源推荐
资源详情
资源评论
收起资源包目录
PyPI 官网下载 | couchbase-3.0.4.tar.gz (206个子文件)
libcouchbase.so.6 17.04MB
make.bat 5KB
ext.c 101KB
callbacks.c 51KB
crypto.c 41KB
bucket.c 38KB
oputil.c 33KB
n1ql.c 23KB
miscops.c 19KB
get.c 19KB
iops.c 17KB
constants.c 16KB
views.c 16KB
store.c 16KB
convert.c 15KB
pycbc_http.c 14KB
multiresult.c 11KB
cntl.c 11KB
counter.c 9KB
opresult.c 9KB
ixmgmt.c 7KB
observe.c 7KB
ctranscoder.c 7KB
fts.c 6KB
exceptions.c 6KB
htresult.c 5KB
result.c 5KB
typeutil.c 5KB
lcb_v4_wrapper.c 3KB
connevents.c 3KB
pipeline.c 3KB
util_wrappers.c 683B
setup.cfg 38B
JSONParser.cmake 10KB
pycbc.h 72KB
lcb_v4_wrapper.h 17KB
oputil.h 16KB
util_wrappers.h 9KB
python_wrappers.h 5KB
pycbc_http.h 4KB
iops.h 2KB
pycbc_subdocops.h 2KB
lcb_dur_wrappers.h 915B
mresdict.h 816B
cbuild_cfg.json 989B
LICENSE 11KB
LICENSE 1KB
Makefile 6KB
README.md 3KB
PKG-INFO 13KB
PKG-INFO 13KB
collection.py 58KB
search.py 47KB
exceptions.py 46KB
cluster.py 42KB
client.py 41KB
scenarios_t.py 22KB
users.py 21KB
bucketmanager.py 20KB
search_t.py 19KB
cluster.py 19KB
search.py 18KB
analytics.py 18KB
collection_t.py 18KB
params.py 17KB
admin.py 17KB
result.py 16KB
n1ql.py 16KB
tracing_t.py 15KB
cbuild_config.py 15KB
queries.py 15KB
iterator.py 15KB
bucket.py 15KB
cluster_t.py 13KB
cluster.py 13KB
buckets.py 12KB
analytics.py 11KB
views.py 11KB
__init__.py 10KB
gen_config.py 10KB
subdocument.py 10KB
cmake_build.py 9KB
querymgmt_t.py 9KB
collections.py 9KB
conf.py 9KB
subdocument.py 9KB
options.py 9KB
analyticsmgmt_t.py 8KB
auth.py 8KB
docloader.py 8KB
client.py 8KB
query_t.py 8KB
admin_t.py 7KB
collectionmgmt_t.py 7KB
binary_collection_t.py 7KB
subdoc_t.py 7KB
crypto.py 6KB
usermgmt_t.py 6KB
items.py 6KB
mutation_state.py 6KB
共 206 条
- 1
- 2
- 3
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于paddle搭建神经网络实现水果识别分类python源码+数据集(高分项目).zip
- 三菱plc编程口通信学习笔记.doc
- 与HIS接口解决方案...doc
- 专利技术交底书-案例模板-软件类-样板示例.doc
- C# 超简单的人脸识别库 .zip
- 实现人脸识别资源代码.zip
- 东北大学-微机原理实验报告及答案-8255并行接口.doc
- 实现人脸检测,人脸识别,人脸标记68个坐标点 人脸对齐 人脸特征测试等 同时可以自行训练人脸识别库.zip
- 基于中科视拓 seetaface6基础源码和JNI源码编译而来的项目.zip
- Python基于opencv人脸识别的考勤系统源码+代码说明(毕业设计).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功