|
import "json" for Json
|
|
|
|
var obj = Json.parse("{\"name\":\"test\",\"value\":42}")
|
|
System.print(obj["name"]) // expect: test
|
|
System.print(obj["value"]) // expect: 42
|
|
|
|
var arr = Json.parse("[1,2,3]")
|
|
System.print(arr[0]) // expect: 1
|
|
System.print(arr.count) // expect: 3
|
|
|
|
var nested = Json.parse("{\"list\":[1,2],\"obj\":{\"a\":\"b\"}}")
|
|
System.print(nested["list"][1]) // expect: 2
|
|
System.print(nested["obj"]["a"]) // expect: b
|
|
|
|
System.print(Json.parse("null") == null) // expect: true
|
|
System.print(Json.parse("true")) // expect: true
|
|
System.print(Json.parse("false")) // expect: false
|
|
System.print(Json.parse("\"hello\"")) // expect: hello
|
|
System.print(Json.parse("3.14")) // expect: 3.14
|