extractJson
extractJson[T](json: String) : T for most types T. One example that T cannot be nor can contain is some OneOf
type.
NQE values can be extracted from a JSON string using the extractJson function.
extractJson[Number]("1")
The above expression will return the NQE value 1 of type Number.
The String value that contains the JSON value ("1" above) is passed to extractJson as a regular argument.
The type of NQE value to be extracted from the JSON value is written between square brackets
prior to the function call's parentheses (Number in the above example).
The following are examples of expressions with extractJson calls and the NQE value that results from evaluating each
expression.
extractJson[Number]("1") => 1extractJson[Bool]("true") => trueextractJson[String]("\"foo\"") => "foo"extractJson[IpAddress]("\"192.168.0.1\"") => 192.168.0.1extractJson[{}]("{}") => {}extractJson[{}]("{\"x\" : 1}") => {}extractJson[{x: Number}]("{\"x\" : 1}") => { x: 1 }extractJson[{x: Number, y: Bool}]("{\"x\": 1, \"y\": true}") => { x: 1, y: true }extractJson[{x?: Number}]("{}") => { x: null }extractJson[{x?: Number}]("{\"x\": null}") => { x: null }extractJson[List<Number>]("[1,2]") => [1, 2]extractJson[List<{x:Number}>]("[{\"x\":1},{\"x\":2}]") => [{ x: 1 }, { x: 2 }]