I have a JSON output from which I need to extract a few parameters in Linux.
This is the JSON output:
{
items:[
{
provider_name:"ucp-ipg",
subject_name:"rtm-instrumentation",
dataset_name:"rtm-instrumentation-dataset-hour-sliced",
dataset_key:[
2018-03-06T06:00:00Z,
"000394e3-a9eb-40b6-9463-fbd588d20ba4"
],
record_count:21,
state:"complete",
version:0,
etag:"a221df62",
creation_timestamp:2018-03-06T06:10:46.294-00:00,
created_by:"AAA",
modification_timestamp:2018-03-06T06:10:46.294-00:00,
modified_by:"AAA"
},
{
provider_name:"ucp-ipg",
subject_name:"rtm-instrumentation",
dataset_name:"rtm-instrumentation-dataset-hour-sliced",
dataset_key:[
2018-03-06T06:00:00Z,
"00097722-b02f-4938-bd4b-d935047c3837"
],
record_count:17,
state:"complete",
version:0,
etag:"aa4dbc25",
creation_timestamp:2018-03-06T06:12:23.293-00:00,
created_by:"AAA",
modification_timestamp:2018-03-06T06:12:23.293-00:00,
modified_by:"AAA"
}
I want the output of
dataset_key:[
2018-03-06T06:00:00Z,
"00097722-b02f-4938-bd4b-d935047c3837"
]
I have already tried with below but not working :
file.txt | python -mjson.tool | grep 'dataset_key'
jq
on it.python -mjson.tool
just passes the input to the output, and grep works one one line at a time. You need to tell the json tool to do the grepping.