New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suberflous \
if try to escape }
in value
#187
Comments
You are not showing us exactly what you get (e.g the diagnosting warning): $ jo foo='\{"bla":"blub"\}' -p
Argument `-p' is neither k=v nor k@v
{"foo":"{\"bla\":\"blub\"\\}"} This is probably not a bug but simply an esacaping thing. I think you'll find this solves your task: $ jo bla=blub > /tmp/f
$ jo foo=@/tmp/f | jq .
{
"foo": "{\"bla\":\"blub\"}"
} |
$ jo -p foo="$(jo bla=blub)"
{
"foo": {
"bla": "blub"
}
}
$ jo -p foo="$(jo bar="$(jo baz="$(jo -a 42 78 hike)")" flurb=tens)"
{
"foo": {
"bar": {
"baz": [
42,
78,
"hike"
]
},
"flurb": "tens"
}
} |
@gromgit quite right, but I'm understanding OP doesn't want the nested object but rather that |
That is not true, maybe my build (binary package from Archlinux) is broken, but I don't get any diagnostics warning here. @gromgit as @jpmens said, I want to have the string instead of the nested object. @jpmens I don't understand why this odd escaping behaviour isn't a bug? I double checked it with both |
Sorry, I misunderstood. Still, assuming you want $ jo -p -- -s foo='{"bla": "blub"}'
{
"foo": "{\"bla\": \"blub\"}"
}
jo -p -- -s foo="$(jo bla=blub)"
{
"foo": "{\"bla\":\"blub\"}"
} Note that the first example actually preserved the space after the colon, proving conclusively that the value was indeed treated as a string instead of being interpreted by |
I invented |
ok, sorry, I tried with
Should have read the manual more in depth. |
Sorry for the comment on a closed issue but I thought it might be helpful to people finding this issue. jo foo=@<(jo bla=blu) |
Hello,
I want to encode some JSON as string value. Therefore I used the trick to escape both the leading
{
and the trailing}
with an\
like this:As you can see, jo adds two
\\
for the trailing}
My expected result would have been:
If only the leading
{
is escaped,jo
detects the value as nested object:Jo Version:
The text was updated successfully, but these errors were encountered: