Skip to content

How to parse JSON Response back to Haskell Type ? #190

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

Open
revskill10 opened this issue Jul 8, 2018 · 5 comments
Open

How to parse JSON Response back to Haskell Type ? #190

revskill10 opened this issue Jul 8, 2018 · 5 comments

Comments

@revskill10
Copy link

Currently, Object doesn't have instance of fromJSON, so how can we convert back Response to Haskell Type from JSON Response ?

@jml
Copy link
Collaborator

jml commented Jul 9, 2018

You would have to write your own parser or submit one as a PR here.

@revskill10
Copy link
Author

revskill10 commented Jul 9, 2018

@jml Any hint to do that ? Because the resulting response type seems arbitrary as a HashMap. My use case is to use with GHCJS.

@jml
Copy link
Collaborator

jml commented Jul 9, 2018 via email

@theobat
Copy link
Contributor

theobat commented Jul 9, 2018

@checkraiser I'm currently writing a converter of a JSON object into a GraphQL haskell type given an existing schema. While my use case is for variables provided as a JSON map, and thus I'm only writing it for InputType, perhaps you'll be able to extend it to fit your use case.

@revskill10
Copy link
Author

revskill10 commented Jul 9, 2018

@theobat Actually i think in this case, the nature of response result type consumed by client is too generic. To actually build up state on client side, we have to use something like aeson-lens to parse. I don't think if there's a better way that we could take advantage of Schema Type here (even in case you can convert into GrpahQL haskell type), you must do another conversion to base data types after all to use it to build client-side state.

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

3 participants