Giter VIP home page Giter VIP logo

purescript-simple-json's Introduction

Purescript-Simple-JSON

build status documentation status

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.readJSON

See 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

Why won't you accept my Pull Request?

Please read this appeal from another open source author: https://github.com/benbjohnson/litestream#open-source-not-open-contribution

How should I actually use this library?

James Brock has informed me that people still do not understand that this library should be used not as a library. If you do not like any of the behavior in this library or would like to opt out of some behaviors, you should copy this library into your own codebase. Please see that this libraries does not actually contain many lines of code and you should be able to learn how to construct this library from scratch with a few days of reading.

purescript-simple-json's People

Contributors

justinwoo avatar jacereda avatar jkachmar avatar dwhitney avatar reactormonk avatar dghaehre avatar xgrommx avatar dretch avatar metame avatar adamczykm avatar mebubo avatar kritzcreek avatar milesfrain avatar tshinohara avatar wryk avatar

Watchers

 avatar

Forkers

srghma

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.