Well, I believe that C
, especially without JSON
library like cjson
is not the appropriate tool to do that.
You might have a look to a list of command-line tools related to JSON:
https://ilya-sher.org/2018/04/10/list-of-json-tools-for-command-line/
I think the best is to download a command-line tool (pre-compiled if possible) and extract the information you need.
An example how to use jq
:
Get outputs from jq on a single line
You can download jq
from here:
https://stedolan.github.io/jq/download/
EDIT: give an example
After jq
download, you can use it from the command line cmd.exe
:
jq-win64.exe
jq - commandline JSON processor [version 1.6]
Usage: jq-win64.exe [options] <jq filter> [file...]
jq-win64.exe [options] --args <jq filter> [strings...]
jq-win64.exe [options] --jsonargs <jq filter> [JSON_TEXTS...]
...
test.json
[{
"name":"name1",
"city":"city1",
"phone":"125698745663"
},
{
"name":"name2",
"city":"city2",
"phone":"125698745663"
}
]
jq
command line:
> jq-win64.exe ".[]|.name+","+.city+","+.phone" test.json
"name1,city1,125698745663"
"name2,city2,125698745663"
.[]
basically means that one wants to iterate over a JSON array
.
|.name
basically means that one wants to extract name
, add a ,
and .city
and so on.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…