• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

justinwoo/purescript-simple-json: A simple Purescript JSON library that uses typ ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

justinwoo/purescript-simple-json

开源软件地址:

https://github.com/justinwoo/purescript-simple-json

开源编程语言:

PureScript 96.5%

开源软件介绍:

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.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
devongovett/protobuf-jsonschema: Compiles Protobuf IDL to JSON Schema发布时间:2022-07-09
下一篇:
YDulanjani/ConvertExcelToJSON发布时间:2022-07-09
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap