我似乎正在努力削减从CloudFlare's API的JSON响应。Cloudflare API截断JSON响应
当我卷曲https://api.cloudflare.com/client/v4/zones/xxxx/settings URL返回所有设置为我的域的JSON响应,如区域:
"editable": true,
"id": "server_side_exclude",
"modified_on": null,
"value": "on"
},
{
"editable": false,
"id": "sha1_support",
"modified_on": null,
"value": "off"
},
{
"editable": false,
"id": "sort_query_string_for_cache",
"modified_on": null,
"value": "off"
},
{
"certificate_status": "active",
"editable": true,
"id": "ssl",
"modified_on": "2016-05-18T14:38:45.665403Z",
"value": "flexible"
这是因为我的课程,由管道将卷曲蟒蛇削减IT -m json.tool。我想实现基本上是打印的一切,例如:
server_side_exclude = on
sha1_support = off
sort_query_string_for_cache = off
(该ID =值)。我试图在不同的变量ID和值存储,例如:
IDs=$(curl https://api.cloudflare.com/client/v4/zones/xxxx/settings | python -m json.tool | grep id)
Values=$(curl https://api.cloudflare.com/client/v4/zones/xxxx/settings | python -m json.tool | grep value)
,然后打印它们彼此相邻。比如用:
echo "$IDs = $Values"
但空空间似乎造成困难。我也尝试通过使用awk和sed来削减回复,但我不熟悉这些工具,也没有成功。
有人更熟悉切割文本请帮助我。先谢谢你。
看看http://stackoverflow.com/questions/12934699/selecting-fields-from-json-output –