Giter Site home page Giter Site logo

lejson's Introduction

Le'Json - Lightweight Erlang Json library

Requires R17 since it produces maps on decode. Not yet handling unicode code points like "\uD8B3" (arabic) correctly. Other than that it seem to keep with the standard (rfc4627).

Latest Tag: 0.5.0

Exports

-spec lejson:decode(iolist()) -> list() | map() | {error, not_json}.
-spec lejson:encode(list() | map()) -> binary().

Example usage

1> l(lejson).
ok
2> M = lejson:decode(<<"{\"boolean\": [true, false],
                         \"neg_num\": -12,
                         \"floats\": [-22.3, -22.3e-12, 22.3E-12,
                                      22.3E+4, 22.3E+4, 22.3E4],
                         \"null\": null,
                         \"pos_int\": 6789,
                         \"string_value\": \"value\",
                         \"utf_value\": \"\\uC3B8 and \\uc2a9\",
                         \"arabic\": \"\\uD8B3\\ud8b5\\ud8b8\",
                         \"more unicode\": \" \\uD834 \\uDD1E \",
                         \"array\": [{\"object_inside_array\": 1}],
                         \"nested_array\": [[[79]]],
                         \"another_array\": [1,2,3,[1,[2],3],12]}">>).
#{<<"another_array">> => [1,2,3,[1,[2],3],12],
  <<"arabic">> => <<216,179,216,181,216,184>>,
  <<"array">> => [#{<<"object_inside_array">> => 1}],
  <<"boolean">> => [true,false],
  <<"floats">> => [-22.3,-2.23e-11,2.23e-11,2.23e5,2.23e5,2.23e5],
  <<"more unicode">> => <<32,216,52,32,221,30,32>>,
  <<"neg_num">> => -12,
  <<"nested_array">> => [["O"]],
  <<"null">> => null,
  <<"pos_int">> => 6789,
  <<"string_value">> => <<"value">>,
  <<"utf_value">> => <<"ø and ©"/utf8>>}
3> lejson:encode(M)
<<"{\"another_array\": [1, 2, 3, [1, [2], 3], 12],\"arabic\": \""...>>

License

Apache license version 2.0. See the LICENSE file for details.

lejson's People

Contributors

cvik avatar f355 avatar rost avatar

Watchers

 avatar  avatar

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.