jason

  Source   Edit

Types

Jason = distinct string
Serialized JSON.   Source   Edit
Jasonable = concept j
    jason(j) is Jason
It should be serializable to JSON.   Source   Edit

Procs

func `$`(j: Jason): string {....raises: [], tags: [].}
Convenience for Jason.   Source   Edit
func jason(node: NimNode): NimNode {....raises: [], tags: [].}
Convenience for jason(...) in macros.   Source   Edit
proc jasonify(node: string): NimNode {....raises: [], tags: [].}
Convenience for Jason(...) in macros.   Source   Edit
proc jasonify(node: NimNode): NimNode {....raises: [], tags: [].}
Convenience for Jason(...) in macros.   Source   Edit
func jason(e: enum): Jason
Render any enum type as a JSON number, by default.   Source   Edit
func jason(i: SomeInteger): Jason
Render any Nim integer as a JSON number.   Source   Edit
func jason(f: SomeFloat): Jason
Render any Nim float as a JSON number.   Source   Edit
func jason(o: ref): Jason
Render a Nim ref as either null or the value to which it refers.   Source   Edit
func jason(node: NimNode): NimNode {....raises: [], tags: [].}
Convenience for jason(...) in macros.   Source   Edit
func jason(e: enum): Jason
Render any enum type as a JSON number, by default.   Source   Edit
func jason(i: SomeInteger): Jason
Render any Nim integer as a JSON number.   Source   Edit
func jason(f: SomeFloat): Jason
Render any Nim float as a JSON number.   Source   Edit
func jason(o: ref): Jason
Render a Nim ref as either null or the value to which it refers.   Source   Edit

Macros

macro jason(js: Jason): Jason
Idempotent Jason handler.

Example:

let j = 3.jason
let k = jason j
assert $k == "3"
  Source   Edit
macro jason(s: string or cstring): Jason
Escapes a string to form "JSON".

Example:

let j = jason"goats"
assert $j == "\"goats\""
  Source   Edit
macro jason(b: bool): Jason
Produce a JSON boolean, either true or false.

Example:

let j = jason(1 == 2)
assert $j == "false"
  Source   Edit
macro jason[I, T](a: array[I, T]): Jason
Render any Nim array as a series of JSON values.   Source   Edit
macro jason(a: JasonArray): Jason
Render an iterable that isn't a named-tuple or object as a JSON array.

Example:

let j = jason @[1, 3, 5, 7]
assert $j == "[1,3,5,7]"
let k = jason (1, 3, 5, 7)
assert $k == "[1,3,5,7]"
  Source   Edit
macro jason(o: tuple): Jason
Render an anonymous Nim tuple as a JSON array; named tuples become JSON objects.

Example:

let j = jason (1, "too", 3.0)
assert $j == """[1,"too",3.0]"""
let k = jason (one: 1, two: "too", three: 3.0)
assert $k == """{"one":1,"two":"too","three":3.0}"""
  Source   Edit
macro jason(o: object): Jason
Render an object as JSON.

Example:

let j = jason Exception(name: "jeff", msg: "bummer")
assert $j == """{"parent":null,"name":"jeff","msg":"bummer","trace":[],"up":null}"""
  Source   Edit
macro jason(b: bool): Jason
Produce a JSON boolean, either true or false.

Example:

let j = jason(1 == 2)
assert $j == "false"
  Source   Edit
macro jason(s: string or cstring): Jason
Escapes a string to form "JSON".

Example:

let j = jason"goats"
assert $j == "\"goats\""
  Source   Edit
macro jason(js: Jason): Jason
Idempotent Jason handler.

Example:

let j = 3.jason
let k = jason j
assert $k == "3"
  Source   Edit
macro jason[I, T](a: array[I, T]): Jason
Render any Nim array as a series of JSON values.   Source   Edit
macro jason(a: JasonArray): Jason
Render an iterable that isn't a named-tuple or object as a JSON array.

Example:

let j = jason @[1, 3, 5, 7]
assert $j == "[1,3,5,7]"
let k = jason (1, 3, 5, 7)
assert $k == "[1,3,5,7]"
  Source   Edit
macro jason(o: tuple): Jason
Render an anonymous Nim tuple as a JSON array; named tuples become JSON objects.

Example:

let j = jason (1, "too", 3.0)
assert $j == """[1,"too",3.0]"""
let k = jason (one: 1, two: "too", three: 3.0)
assert $k == """{"one":1,"two":"too","three":3.0}"""
  Source   Edit
macro jason(o: object): Jason
Render an object as JSON.

Example:

let j = jason Exception(name: "jeff", msg: "bummer")
assert $j == """{"parent":null,"name":"jeff","msg":"bummer","trace":[],"up":null}"""
  Source   Edit

Templates

template staticJason(typ: typedesc)
Create a static JSON encoder for type typ.   Source   Edit