All Projects → state-machine-systems → JsonCodec

state-machine-systems / JsonCodec

Licence: Apache-2.0 license
JSON combinator library for BuckleScript/Reason

Programming Languages

C++
36643 projects - #6 most used programming language
ocaml
1615 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to JsonCodec

markdown-reason-react
Generate ReasonReact Pages from Markdown
Stars: ✭ 17 (-55.26%)
Mutual labels:  reasonml
reason-rust-scraper
🦀 Scraping & crawling websites using Rust, and ReasonML
Stars: ✭ 21 (-44.74%)
Mutual labels:  reasonml
ideas-for-project-names-starting-with-re
No description or website provided.
Stars: ✭ 27 (-28.95%)
Mutual labels:  reasonml
ts2re
Convert TypeScript type declarations to Reason
Stars: ✭ 32 (-15.79%)
Mutual labels:  reasonml
turaku-client
Web / Electron client application for Turaku
Stars: ✭ 27 (-28.95%)
Mutual labels:  reasonml
reason-react-lazy-loading
Example project to show how to use components lazy loading in ReasonReact
Stars: ✭ 41 (+7.89%)
Mutual labels:  reasonml
bs-decode
Type-safe JSON decoding for ReasonML and OCaml
Stars: ✭ 105 (+176.32%)
Mutual labels:  reasonml
reasonml-tic-tac-toe
www.imandra.ai
Stars: ✭ 19 (-50%)
Mutual labels:  reasonml
rekernel
A minimal setup for writing Unikernels in ReasonML
Stars: ✭ 28 (-26.32%)
Mutual labels:  reasonml
rx-reason
Reactive programming library for ReasonML/OCaml
Stars: ✭ 49 (+28.95%)
Mutual labels:  reasonml
re-hyperapp
Almost zero-cost bindings for the https://github.com/hyperapp/hyperapp UI library.
Stars: ✭ 21 (-44.74%)
Mutual labels:  reasonml
bacen-exchange-rates
Reason API to fetch the daily reports from BACEN PTAX exchanges
Stars: ✭ 16 (-57.89%)
Mutual labels:  reasonml
bs-dynamic-import
📦🚀 BuckleScript dynamic import interop on JavaScript environment
Stars: ✭ 31 (-18.42%)
Mutual labels:  reasonml
refabricator
Static Site Generator for/in ReasonML
Stars: ✭ 31 (-18.42%)
Mutual labels:  reasonml
ogaml
Ocaml multimedia library
Stars: ✭ 28 (-26.32%)
Mutual labels:  reasonml
rembrandt
Simple UI framework written in Reasonml.
Stars: ✭ 81 (+113.16%)
Mutual labels:  reasonml
react-rules-of-hooks-ppx
This ppx validates the rules of React hooks.
Stars: ✭ 40 (+5.26%)
Mutual labels:  reasonml
LifeTime
LifeTime app
Stars: ✭ 35 (-7.89%)
Mutual labels:  reasonml
sonos-wejay
Slack integration for a local Sonos system
Stars: ✭ 19 (-50%)
Mutual labels:  reasonml
remachine
[WIP] Reason pattern matching viz
Stars: ✭ 44 (+15.79%)
Mutual labels:  reasonml

JsonCodec

JSON combinator library for BuckleScript/Reason

Using the magic of pickler combinators, this library allows you to parse and serialize JSON structures in a declarative way, free of boilerplate.

Here's a little example:

let json = {js|
{
    "name": "Great Pyramid of Giza",
    "lat": 29.979175,
    "lon": 31.134358,
    "height": 146.5
}
|js};

/* Define a codec for the above object type */
let codec =
  JsonCodec.(
    object4(
      field("name", string),
      field("lat", number),
      field("lon", number),
      field("height", number),
    )
  );

/* Decoding */
switch (JsonCodec.decodeJson(codec, json)) {
| Belt.Result.Ok((name, lat, lon, height)) =>
  Printf.printf("name='%s' location=%f,%f height=%f\n", name, lat, lon, height)
| Belt.Result.Error(error) => Printf.printf("Decoding error: %s", error)
};

/* Encoding */
let encoded =
  JsonCodec.encodeJson(codec, ("Machu Picchu", -13.163333, -72.545556, 2430.0));

Printf.printf("JSON: %s\n", encoded);

© 2017-2018 State Machine Systems Ltd. Apache Licence, Version 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].