Closed tgoeg closed 4 years ago
Double curly brackets is the intended way.
It's a "feature". Single curly brackets are for calculations. E.g. -d "{1 + 2 + 3}"
would send 6.
The function can be used like: -d '{serialize-json({"method":"get_session_key"})}'
Parsing happens automatically. It creates a variable $json
for use in the -e
expression. The xidel 0.9.9 development builds also support the xpath 3.1 syntax, ?key
or ?*
to read values
Thanks, I understand now. This should probably be part of the documentation!
I am trying to send JSON data to an API.
I was unable to use the json-serialize() function to do the actualy JSON structuring, but I am a complete newbie to xpath/xquery and xidel. Maybe that's not possible at all.
Sending JSON however is possible by using double curly brackets.
I don't know if this is intended - at least it is not documented. But this works:
What is the intended way of sending/posting JSON data and parsing the result again (in bash)?