-
Notifications
You must be signed in to change notification settings - Fork 46
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 readJSON for completely empty input? #66
Comments
Regardless what you use, the initial JSON parsing will fail when dealing with the invalid JSON string. ReadForeign really only deals with how to deal with actual |
You don't have to take my word for it, look at how the readJSON methods work by first calling parseJSON, which is a separate function: purescript-simple-json/src/Simple/JSON.purs Lines 64 to 77 in c5e2b7b
purescript-simple-json/src/Simple/JSON.purs Lines 129 to 139 in c5e2b7b
|
Ack, sorry for the delay here. You're right, of course; when I made this ticket I had forgotten that a completely blank input is indeed invalid JSON. For anybody else that might stumble on this: what we ended up doing was parameterizing our request method on a "how to handle the response" input (more or less of type Closing this, thank you! |
Hey there,
I'm using Affjax to execute requests, defining the response format as String, and then using readJSON to parse the response into some type defined by the caller. I have a request, though, where the success response is nothing, i.e. completely empty. I tried defining the
a
in readJSON to be String, Maybe String, Nullable String, Foreign, etc but it all returns a parse error on the readJSON call. What I think I need is an instance for ReadForeign Unit that looks like:such that callers that expect the response to be completely empty can define that in the type and have a useless result be returned back in that slot. Can you foresee any issues with this or do you have any other suggestions for what to do here?
The text was updated successfully, but these errors were encountered: