lens / lens-aeson

Traversals and Prisms for Data.Aeson
MIT License
51 stars 18 forks source link

Decode `ByteString`s to UTF-8 leniently #50

Closed RyanGlScott closed 2 years ago

RyanGlScott commented 2 years ago

While JSON values are assumed to be UTF-8–encoded, there are some exposed functions that can be provided non–UTF-8–encoded inputs, such as the _Key implementations for ByteStrings. Just in case a user provides inputs to these functions that are not non–UTF-8–encoded, this patch replaces the use of decodeUtf8 with decodeUtf8With lenientDecode. That way, rather than having these inputs crash the program, the offending characters will simply be replaced with Unicode replacement characters.

Fixes #48.

phadej commented 2 years ago

Thanks. this looks good.