Skip to content

better-mojo/EmberJson

 
 

Repository files navigation

EmberJson

A lightweight JSON parsing library for Mojo.

Usage

from ember_json import *

fn main() raises:
    # parse string
    var s = '{"key": 123}'
    var json = JSON.from_string(s)

    print(json.is_object()) # prints true

    # fetch inner value
    var ob = json.object()
    print(ob["key"].int()) # prints 123
    # implicitly acces json object
    print(json["key"].int()) # prints 123

    # json array
    s = '[123, 456]'
    json = JSON.from_string(s)
    var arr = json.array()
    print(arr[0].int()) # prints 123
    # implicitly access array
    print(json[1].int()) # prints 456

    # `Value` type is formattable to allow for direct printing
    print(json[0]) # prints 123

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Mojo 94.3%
  • Python 4.5%
  • Shell 1.2%