想要解析json
:
{"FileStatus":"accessTime":1472892839430,"blockSize":134217728,"childrenNum":0,"fileId":17226,"group":"admin","length":115714,"modificationTime":1469649837471,"owner":"admin","pathSuffix":"","permission":"755","replication":2,"storagePolicy":0,"type":"FILE"}}
我尝试了类似的东西但却无法得到它。
$ {"FileStatus":{"accessTime":1472892839430}} | jq '.FileStatus.accessTime'
错误:
-bash: {FileStatus:{accessTime:1472892839430}}: command not found`
有人可以帮我解析整个json
。
答案 0 :(得分:0)
要使命令在bash中读取stdin上的字符串,请使用"here string",如下所示:
qUserActivity.findObjectsInBackground(block: {(objects, error) in
if error != nil{
print(error)
}else {
total = (objects?.count)!
total = 1
}
//Update the ui thread here?
})
此外,您需要正确引用文本,以便bash不会尝试以某种方式解释您不打算。如果您想按字面意思保留它,请使用single quotes($ jq '.FileStatus.accessTime' <<<'{"FileStatus":{"accessTime":1472892839430}}'
1472892839430
)。