JSON parsing with accumulative errors
- Dominant language
- Haskell
- Stars
- 1.3k
- Forks
- 336
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 4
Description
When parsing an incorrect JSON with Aeson, you only get the first error instead of all the errors like so:
```
Data.Aeson> eitherDecode "[1,19,\"a\", 20]" :: Either String [Text]
Left "Error in $[0]: expected Text, encountered Number"
```
It would be better to have another function to return all the errors instead of just the first one, for example:
```
Data.Aeson> eitherDecode "[1,19,\"a\", 20]" :: Either [(String, String)] [Text]
Left [("$[0]", "Expected Text, encountered Number"), ("$[1]", "Expected Text, encountered Number"), ("$[3]", "Expected Text, encountered Number")]
```
This kind of feature would be very useful in web development where errors in request payload are all checked at once to save network round trip.
I'm thinking maybe this library can be used instead of `Either` https://hackage.haskell.org/package/Validation-0.2.0/docs/Data-Validation.html
Contributor guide
Research direction
Start by reading Data.Aeson.eitherDecode and the existing error behavior shown in the issue, then review the linked Data.Validation API. Determine how an additional parsing function should represent multiple paths and errors; done means incorrect arrays report all invalid elements while preserving the existing decoding behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100