Reputation: 71
Consider I have the below JSON:
{
"id": "Ab12",
"details": "{\"timeValue\":null,\"lastModifiedIn\":\"PHX\"}",
"version": 3
}
I want to extract the value of 'lastModifiedIn' key without using the jq command. Basically, the result I seek for is 'PHX'.
Is there a way to extract this using basic shell scripting?
Upvotes: 1
Views: 1710
Reputation: 203645
It's sloppy but given the input and your requirement to not use jq
this might be good enough for your purposes:
$ sed -n 's/.*"lastModifiedIn\\":\\"\([^\\]*\).*/\1/p' file
PHX
Upvotes: 4