1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| protected override func onPageShow() {
let dd = Abc() let aa: JsonValue = dd.serialize().toJson() let bb: JsonObject = (aa as JsonObject).getOrThrow() let v1 = (bb.get("name").getOrThrow() as JsonString).getOrThrow() let v2 = (bb.get("age").getOrThrow() as JsonInt).getOrThrow() let v3 = bb.get("loc").getOrThrow() Hilog.printInfo("printInfo",v1.getValue()) Hilog.printInfo("printInfo",v2.getValue().toString()) Hilog.printInfo("printInfo",v3.toString()) Hilog.printInfo("printInfo","===========") let aaa = ##"{"age": 123, "loc": { "heheh": "H", "time": 45 }, "name": "zhangsan"}"## let bbb = JsonValue.fromStr(aaa) let ccc = (bbb as JsonObject).getOrThrow() let v4 = (ccc.get("name").getOrThrow() as JsonString).getOrThrow() let v5 = (ccc.get("age").getOrThrow() as JsonInt).getOrThrow() let v6 = (ccc.get("loc").getOrThrow() as JsonObject).getOrThrow() let v7 = (v6.get("time").getOrThrow() as JsonInt).getOrThrow() let v8 = (v6.get("heheh").getOrThrow() as JsonString).getOrThrow() Hilog.printInfo("printInfo",v4.getValue()) Hilog.printInfo("printInfo",v5.getValue().toString()) Hilog.printInfo("printInfo",v7.getValue().toString()) Hilog.printInfo("printInfo",v8.getValue().toString())
} //Hilog扩展 extend Hilog{ static func printInfo(tag: String, format: String){ Hilog.info(1, tag,format) } }
|