ob-restclient.el icon indicating copy to clipboard operation
ob-restclient.el copied to clipboard

cannot remove quotes from JSON return results

Open vladp opened this issue 2 years ago • 4 comments

Hello I am trying to remove quotes from:

{ "data": "some value but I do not need quotes" }

Using the following:


#+NAME: get-token-without-quotes
#+BEGIN_SRC restclient  :results value verbatim  :var uname=user_name  :var pass=mypass :jq .data
POST https://api.getstuff/login
Content-Type: application/json
{
        "un": ":uname",
	"p": ":pass"
}
#+END_SRC

jq documentation says to use -r command line argument, however when pass -r .data , I get an error from JQ that invocation was not correct

So how do I remove quotes from get-token-without-quotes string for subsequent invocation of another REST API call ?

thank you in advance

vladp avatar Aug 22 '22 01:08 vladp

We currently don’t support extra arguments to jq.

I see how this can be useful, so I’ll accept a pull request for this. I might implement it myself later, but my schedule won’t allow it for now. Sorry.

alf avatar Sep 04 '22 20:09 alf

Good issue, same problem here.

wisetc avatar Sep 11 '22 14:09 wisetc

Try to use bash echo command to output the string without quotes

#+name: ticket
#+BEGIN_SRC bash :var ticket_with_quote=ticket_with_quote :results value
echo $ticket_with_quote
#+END_SRC

wisetc avatar Sep 11 '22 14:09 wisetc

@wisetc thank you, that works for me. it adds an extra section, so I have to add about 6 more sections, but this worked.

vladp avatar Sep 11 '22 20:09 vladp