Skip to content
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

Relax top-level restriction of parseJSON #364

Open
matil019 opened this issue Aug 5, 2018 · 1 comment
Open

Relax top-level restriction of parseJSON #364

matil019 opened this issue Aug 5, 2018 · 1 comment

Comments

@matil019
Copy link
Member

matil019 commented Aug 5, 2018

As described in the fregedoc, parseJSON fails if it is decoding a string neither into an object nor an array:

import frege.data.JSON

main = println $ (parseJSON "true" :: Maybe Bool)
-- prints "Nothing"

However, since Bool is an instance of FromJSON it's misleading.

It's true that any valid JSON should have an object or an array as its top-level entity. However, I think it's applications' responsibility to check the validity of a JSON, and the implementation of the library should be consistent to its type.

@talios
Copy link
Contributor

talios commented Aug 6, 2018 via email

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

2 participants