B4J Question Problem with JSON string describing menu items

T201016

Active Member
Licensed User
Longtime User
Hi,
I have the following JSON string describing the menu items:

{Text: "_Help", Children:
[
{Text: "Show Zip Result Window", Selected: True, Shortcut: {Key: "F1"}}
]
}

Can someone tell me how to translate this into source code in B4J?
I can't get "Selected: True"
Example:
MenuItem:
    ...
   
    Dim MI As MenuItem
    MI.Initialize("Show Zip Result Window","Menu")
    BLD_Utils.SetShortCutKey(MI,Array As String("Ctrl","R"))
    M.MenuItems.Add(MI)
    MenuBar1.Menus.Add(M)
   
'Set a shortcut key for this menu item
'Returns the menu item
Public Sub SetShortCutKey(MI As JavaObject,Combination() As String) As MenuItem
    Dim KC As JavaObject
    KC.InitializeStatic("javafx.scene.input.KeyCombination")
    Dim KCS As String
    For i = 0 To Combination.Length - 1
        If i > 0 Then KCS = KCS & "+"
        KCS = KCS & Combination(i)
    Next
    MI.RunMethod("setAccelerator",Array(KC.RunMethod("keyCombination",Array(KCS))))
    Return MI
End Sub
 
Last edited:
Solution
Can someone tell me how to translate this into source code in B4J?
I can't get "Selected: True"
B4X:
Dim parser As JSONParser
parser.Initialize($"
{Text: "_Help", Children:
[
{Text: "Show Zip Result Window", Selected: True, Shortcut: {Key: "F1"}}
]
}"$)
Dim jRoot As Map = parser.NextObject
Dim Text As String = jRoot.Get("Text")
Dim Children As List = jRoot.Get("Children")
For Each colChildren As Map In Children
 Dim Shortcut As Map = colChildren.Get("Shortcut")
 Dim Key As String = Shortcut.Get("Key")
 Dim Text As String = colChildren.Get("Text")
 Dim Selected As String = colChildren.Get("Selected")
Next

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Can someone tell me how to translate this into source code in B4J?
I can't get "Selected: True"
B4X:
Dim parser As JSONParser
parser.Initialize($"
{Text: "_Help", Children:
[
{Text: "Show Zip Result Window", Selected: True, Shortcut: {Key: "F1"}}
]
}"$)
Dim jRoot As Map = parser.NextObject
Dim Text As String = jRoot.Get("Text")
Dim Children As List = jRoot.Get("Children")
For Each colChildren As Map In Children
 Dim Shortcut As Map = colChildren.Get("Shortcut")
 Dim Key As String = Shortcut.Get("Key")
 Dim Text As String = colChildren.Get("Text")
 Dim Selected As String = colChildren.Get("Selected")
Next
 
Upvote 0
Solution
Top