Skip to content

A Yojson-like library for ReasonML, both Native & JavaScript

License

Notifications You must be signed in to change notification settings

lojikil/rosejson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RoseJSON Overview

RoseJSON is a Yojson-like library with zero dependencies. It can be used with ReasonML native (via dune) or with JavaScript (via bsb). I currently use this in processing a large corpus of JSON files with both.

Usage

let jsond = RoseJSON.from_string({|{"test":[1,2,3], "this":{"thing":[4,5,6]}}|}); //(1)
let inner_data = jsond |> RoseJSON.member("this") |> RoseJSON.member("thing") |> RoseJSON.to_array |> List.map(RoseJSON.to_int); //(2)
  1. RoseJSON only provides a from_string parser, which returns a RoseJSON.t object

  2. We can build Yojson-like pipeliness for members

To Do

  1. The inner parsing of JSON is atrocious currently; I wrote something "good enough" to get started, but work can be done there

    1. I was thinking about a simple Buffer-like interface that can be shunted around with pipe-last

  2. A Native interface would be nice; something that presents the same RoseJSON.t but using a different backend

    1. Js.Json in JavaScript Targets

    2. Yojson or the like in Native targets

  3. Speed increase; it’s generally fine for Native code, but in JavaScript, JSON data over 10k can get S L O W

    1. It’s effectively unusable for JSON data over 100k; I switched to a Native build internally because of this, and it was sub-1s

About

A Yojson-like library for ReasonML, both Native & JavaScript

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages