diff options
| author | bhgv <bhgv.empire@gmail.com> | 2018-03-01 16:54:45 +0200 |
|---|---|---|
| committer | bhgv <bhgv.empire@gmail.com> | 2018-03-01 16:54:45 +0200 |
| commit | b786f20bbab5a59046aa78a2c6c2a11536497202 (patch) | |
| tree | 0851ecdec889eb9b7ba3751cc04d4f0b474e4a9e /module/json.m | |
inferno-os tree was separated from the inferno-os-android (separated from the Android driver)
Diffstat (limited to 'module/json.m')
| -rw-r--r-- | module/json.m | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/module/json.m b/module/json.m new file mode 100644 index 0000000..48f5fd9 --- /dev/null +++ b/module/json.m @@ -0,0 +1,50 @@ +JSON: module +{ + PATH: con "/dis/lib/json.dis"; + + JValue: adt { + pick{ + Object => + mem: cyclic list of (string, ref JValue); + Array => + a: cyclic array of ref JValue; + String => + s: string; + Int => + value: big; # could use IPint? # just use Number (as string) + Real => + value: real; + True or False or Null => + } + + isarray: fn(o: self ref JValue): int; + isfalse: fn(o: self ref JValue): int; + isint: fn(o: self ref JValue): int; + isnull: fn(o: self ref JValue): int; + isnumber: fn(o: self ref JValue): int; + isobject: fn(o: self ref JValue): int; + isreal: fn(o: self ref JValue): int; + isstring: fn(o: self ref JValue): int; + istrue: fn(o: self ref JValue): int; + copy: fn(o: self ref JValue): ref JValue; + eq: fn(a: self ref JValue, b: ref JValue): int; + get: fn(a: self ref JValue, n: string): ref JValue; + set: fn(a: self ref JValue, mem: string, value: ref JValue); + text: fn(a: self ref JValue): string; + }; + + init: fn(bufio: Bufio); + readjson: fn(buf: ref Bufio->Iobuf): (ref JValue, string); + writejson: fn(buf: ref Bufio->Iobuf, val: ref JValue): int; + + # shorthand? + jvarray: fn(a: array of ref JValue): ref JValue.Array; + jvbig: fn(b: big): ref JValue.Int; + jvfalse: fn(): ref JValue.False; + jvint: fn(i: int): ref JValue.Int; + jvnull: fn(): ref JValue.Null; + jvobject: fn(m: list of (string, ref JValue)): ref JValue.Object; + jvreal: fn(r: real): ref JValue.Real; + jvstring: fn(s: string): ref JValue.String; + jvtrue: fn(): ref JValue.True; +}; |
