Discussion:
Get a property value from JSON
'Siamack J. Farshi' safamack@hotmail.com [sed-users]
2018-06-23 13:03:46 UTC
Permalink
Hi everyone,


I was wondering what is the best way given a JSON payload from a CURL command to retrieve a value of a property.Namely a JSON payload like follows. Also assuming that 'property' names are unique across the payload even if there are nested elements


{

"property1": "value1"

"property2: "value2"

"porperty3 : [

{

"property4": "value4"

}

]

}


Thank you.


[Non-text portions of this message have been removed]
Jim Hill gjthill@gmail.com [sed-users]
2018-06-23 17:15:33 UTC
Permalink
On Sat, Jun 23, 2018 at 6:03 AM 'Siamack J. Farshi'
Post by 'Siamack J. Farshi' ***@hotmail.com [sed-users]
given a JSON payload from a CURL command to retrieve a value of a property.
Don't do that with `sed`. Use `jq`, `jq -a .property1 yourfile` (or
`-r` for even less decoration)
Daniel Goldman dgoldman@ehdp.com [sed-users]
2018-06-24 01:53:09 UTC
Permalink
"Use jq" - Thanks! That's very useful to know. "Namely a JSON payload
like follows" - Just as a point of information, the JSON syntax is
messed up in several ways. Daniel
Post by Jim Hill ***@gmail.com [sed-users]
On Sat, Jun 23, 2018 at 6:03 AM 'Siamack J. Farshi'
Post by 'Siamack J. Farshi' ***@hotmail.com [sed-users]
given a JSON payload from a CURL command to retrieve a value of a property.
Don't do that with `sed`. Use `jq`, `jq -a .property1 yourfile` (or
`-r` for even less decoration)
------------------------------------
------------------------------------
Loading...