[Haskell-beginners] Re: question about show -- RWH chapter 5
bbxx789_05ss at yahoo.com
Thu Mar 26 12:04:19 EDT 2009
Peter Verswyvelen <bugfact <at> gmail.com> writes:
> Well, for JSON, I think the rendered string must be enclosed in double quotes,
> which is what the show instance for String does.
Ahh. I see. My version yields this output:
main = let x = JString "hello"
y = JNumber 10
rx = renderJValue x
ry = renderJValue y
in putStrLn ("[" ++ rx ++ ", " ++ ry ++ "]")
...and that is not correct JSON format. hello looks like a variable
name--not a string. The books version produces:
More information about the Beginners