Can someone please take a look, thank you
json file is
{"tvset": {
"topic": "a/update",
"sectet": "test",
"head": "wei",
"id": "文件",
"value": "文件",
"keyboard": {
"menuitem": [
{"value": "新建","onclick": "CreateNewDoc()"},
{"value": "打开","onclick": "OpenDoc()"},
{"value": "关闭","onclick": "CloseDoc()"}
]
}
}
}
B4A
error log
** Activity (main) Create, isFirst = true **
Error occurred on line: 32 (Main)
java.lang.RuntimeException: Object should first be initialized (Map).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
at anywheresoftware.b4a.objects.collections.Map.Get(Map.java:64)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.samples.json.main.afterFirstLayout(main.java:105)
at anywheresoftware.b4a.samples.json.main.access$000(main.java:17)
at anywheresoftware.b4a.samples.json.main$WaitForLayout.run(main.java:83)
json file is
{"tvset": {
"topic": "a/update",
"sectet": "test",
"head": "wei",
"id": "文件",
"value": "文件",
"keyboard": {
"menuitem": [
{"value": "新建","onclick": "CreateNewDoc()"},
{"value": "打开","onclick": "OpenDoc()"},
{"value": "关闭","onclick": "CloseDoc()"}
]
}
}
}
B4A
B4X:
Dim JSON As JSONParser
Dim Map1 As Map
JSON.Initialize(File.ReadString(File.DirAssets, "example.json"))
Map1 = JSON.NextObject
Dim m As Map 'helper map for navigating
Dim MenuItems As List
MenuItems.Initialize
m = Map1.Get("tvset")
m = m.Get("keyboad")
MenuItems = m.Get("menuitem")
For i = 0 To MenuItems.Size - 1
m = MenuItems.Get(i)
Log(m.Get("value"))
Next
error log
** Activity (main) Create, isFirst = true **
Error occurred on line: 32 (Main)
java.lang.RuntimeException: Object should first be initialized (Map).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
at anywheresoftware.b4a.objects.collections.Map.Get(Map.java:64)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.samples.json.main.afterFirstLayout(main.java:105)
at anywheresoftware.b4a.samples.json.main.access$000(main.java:17)
at anywheresoftware.b4a.samples.json.main$WaitForLayout.run(main.java:83)