Skip to content
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

How to decode an http/get transit json response to a edn? #103

Open
viebel opened this issue Sep 24, 2016 · 3 comments
Open

How to decode an http/get transit json response to a edn? #103

viebel opened this issue Sep 24, 2016 · 3 comments

Comments

@viebel
Copy link

viebel commented Sep 24, 2016

My response is in transit json and I need to convert it to edn.

cljs-http automatically converts the json into a cljs object.

So for the moment, I am doing:

(-> json
      clj->js
      js/JSON.stringify
      (transit-decode :json nil))

But I'm sure there is a better way.

@viebel viebel changed the title How to decode an http/get transit json response to a edn How to decode an http/get transit json response to a edn? Sep 24, 2016
@r0man
Copy link
Owner

r0man commented Sep 30, 2016

@viebel I'm on holiday at the moment and AFK most of the time. What do you mean by " I need to convert it to edn"? An EDN string? I guess you want Clojure maps and vectors. cljs-http should decode transit json responses automatically, provided you set the "Content-Type" header to "application/transit+json".

@viebel
Copy link
Author

viebel commented Sep 30, 2016

You guessed right. I want a clojurescript object. The problem is that I cannot modify the "Content-Type" header. Is there a way to tell receive the string as is?

@r0man
Copy link
Owner

r0man commented Sep 30, 2016

@viebel This is not possible at the moment I think. Patch that mimics the behaviour of clj-http welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants