Closed lsh-0 closed 2 months ago
The @fromstr
modifier is used to unescape json that is stored in a string.
Using the path person.@fromstr.last
with json
{"person":"{\"last\":\"Anderson\"}"}
returns "Anderson"
.
ah ... so is there an equivalent to jq --raw-output
that would let me get at the string Anderson
without quotes?
gjson.Get("name.last").String()
Unfortunately the path is passed in by the user, much like https://gjson.dev
@fromstr: Converts a string from json. Unwraps a json string.
It sounds like what I need but I was mistaken. Thanks for your time.
No problem, glad you found a solution.
Using https://gjson.dev, an input of:
yields
and I would expect using the modifier
@fromstr
like:to yield:
(without quotes), instead nothing is displayed.
Locally the
extracted_value.Exists()
is returningfalse
.Am I using
@fromstr
correctly? I've also triedsome.path.@fromstr
as well downgrading togjson@1.16.0
with the same results.Thanks,