agrafix / Spock

Another Haskell web framework for rapid development
https://www.spock.li
678 stars 56 forks source link

How to respond with JSON #88

Closed xiutxu closed 8 years ago

xiutxu commented 8 years ago

Instead of sending back a text response, how can I send back a json response?

sqd commented 8 years ago

Use json

xiutxu commented 8 years ago

Should I be using json for questions which pertain to Spock?

xiutxu commented 8 years ago

@sqd I tried for a little while to use json, but I couldn't figure out how make

[{"name":"tesla","id":"7781ee7e-1e43-4608-bb96-fe10cac3b53a"}]

the desired datatype. I will need to look at https://hackage.haskell.org/package/aeson-0.10.0.0/docs/Data-Aeson-Types.html#t:ToJSON a little more closely. Here's the full problem if anyone cares :) https://mail.haskell.org/pipermail/beginners/2016-August/017050.html

sqd commented 8 years ago

@xiutxu What do you mean by "questions which pertain to Spock"?

If you just want a quick and dirty type-unsafe JSON conversion, you could use toJSON [object ["name" .= "tesla", "id" .= "..."]]

brezal commented 8 years ago

@sqd, I have a feeling I will run into many things which I want to discuss when starting to use Spock. I don't mind placing my queries here,but I understand this may not be the place for it.

agrafix commented 8 years ago

You could use the mailing list at haskell-spock@googlegroups.com