Got the #MidnightMurderParty editor back in working condition! As I thought, tonight was dedicated to entirely rewriting the #JSON encoding/decoding using #PureScript Argonaut. Mostly, it was pretty simple—just a lot of rewriting—but I did run into one super sneaky “gotcha!” right at the end. For some reason, my encoding was leaving out a field, no matter what I was encoding.
"secretKey" := secretKey ~> "data" := postData
This was leaving out the
"data" field, for example. I only figured out what was wrong because, after the server got mad at me for sending bad data (or no
"data", rather), I dumped my other JSON to the console and dug through the keys until I spotted the correlation. Whichever field was encoded last just didn’t get encoded at all.
Turns out the fix was simple:
"secretKey" := secretKey ~> "data" := postData ~> jsonEmptyObject
Yup, just slap an empty JSON object onto the end of the extend (
~>) chain, and it works.