discord test stars

About

JSON decoding in the Mys programming language.

Project: https://github.com/mys-lang/package-json

API

trait Value:
    A value in a JSON document.

    func object(self) -> {string: Value}:
        As an object. Raises an error for non-object values.

    func get(self, key: string) -> Value:
        As an item in an object. Raises an error for non-object values and
        if the key is missing.

    func list(self) -> [Value]:
        As a list. Raises an error for non-list values.

    func at(self, index: i64) -> Value:
        As an item in a list. Raises an error for non-list values.

    func string(self) -> string:
        As a string. Raises an error for non-string values.

    func integer(self) -> i64:
        As an integer. Raises an error for non-integer values.

    func float(self) -> f64:
        As a float. Raises an error for non-float values.

    func bool(self) -> bool:
        As a boolean. Raises an error for non-bool values.

    func null(self):
        As null. Raises an error for non-null values.
class JsonError(Error):
    message: string
class Object(Value):
    An object.

    items: {string: Value}

    func __init__(self):

    func object(self) -> {string: Value}:

    func get(self, key: string) -> Value:
class List(Value):
    A list.

    items: [Value]

    func __init__(self):

    func list(self) -> [Value]:

    func at(self, index: i64) -> Value:
class String(Value):
    A string.

    value: string

    func string(self) -> string:
class Integer(Value):
    An integer.

    value: i64

    func integer(self) -> i64:
class Float(Value):
    A float.

    value: f64

    func float(self) -> f64:
class Bool(Value):
    A boolean.

    value: bool

    func bool(self) -> bool:
class Null(Value):
    Null.

    func null(self):
func decode(data: string) -> Value:
    Decode given JSON string.