Purescript-Simple-JSON
A simple Foreign/JSON library based on the Purescript's RowToList feature.
Quickstart
Get going quickly with the Quickstart section of the guide: https://purescript-simple-json.readthedocs.io/en/latest/quickstart.html
You may also be interested in this presentation about how Simple-JSON works well with PureScript-Record: https://speakerdeck.com/justinwoo/easy-json-deserialization-with-simple-json-and-record. Note that the slides are based on an older version of the library and on PureScript 0.11.6, and it is not necessary to understand these slides to get started.
Usage
In brief:
type MyJSON =
{ apple :: String
, banana :: Int
, cherry :: Maybe Boolean
}
decodeToMyJSON :: String -> Either (NonEmptyList ForeignError) MyJSON
decodeToMyJSON = SimpleJSON.readJSONSee the API Docs or the tests for usage.
There is also a guide for how to use this library on Read the Docs.
Warning: Maybe
This library will decode undefined and null as Nothing and write Nothing as undefined. Please use the Nullable type if you'd like to read and write null instead. Please take caution when using Maybe as this default may not be what you want.
FAQ
How do I use this with Affjax?
Please see this page in the guide: https://purescript-simple-json.readthedocs.io/en/latest/with-affjax.html
How do I change how some fields of my JSON objects are read?
Please see this page in the guide: https://purescript-simple-json.readthedocs.io/en/latest/inferred-record-types.html
How do I work with data Types?
Please see this page in the guide: https://purescript-simple-json.readthedocs.io/en/latest/generics-rep.html

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
