I have such a JSON:
In Code:{
"name": "hauptprogramm",
"headers": {
"Datei" : [{
"name": "Mandant wechseln",
"showIcon": true,
"iconName": "Icon_Change"
},
{
"name": "Beenden",
"showIcon": true,
"iconName": "Icon_Exit"
}]
}
}
Code: Select all
JSON$ = ~"{" + #LF$
JSON$ + ~" \"name\": \"hauptprogramm\"," + #LF$
JSON$ + ~" \"headers\": {" + #LF$
JSON$ + ~" \"Datei\" : [{" + #LF$
JSON$ + ~" \"name\": \"Mandant wechseln\"," + #LF$
JSON$ + ~" \"showIcon\": true," + #LF$
JSON$ + ~" \"iconName\": \"Icon_Change\"" + #LF$
JSON$ + ~" }," + #LF$
JSON$ + ~" {" + #LF$
JSON$ + ~" \"name\": \"Beenden\"," + #LF$
JSON$ + ~" \"showIcon\": true," + #LF$
JSON$ + ~" \"iconName\": \"Icon_Exit\"" + #LF$
JSON$ + ~" }]" + #LF$
JSON$ + ~" }" + #LF$
JSON$ + ~"}"
Code: Select all
Structure JsonMenuEntry
name.s
showIcon.i
iconName.s
EndStructure
Structure JsonMenuHeader
List Datei.JsonMenuEntry()
List Bearbeiten.JsonMenuEntry()
EndStructure
Structure JsonMenuTemplate
name.s
headers.JsonMenuHeader
EndStructure
"Datei" and "Bearbeiten" should not be in the structure.
My only solutions needs an additional name
Code: Select all
Structure JsonMenuEntry
name.s
showIcon.i
iconName.s
EndStructure
Structure JsonMenuHeader
List A.JsonMenuEntry()
EndStructure
Structure JsonMenuTemplate
name.s
Map headers.JsonMenuHeader()
EndStructure
Define.JsonMenuTemplate template
template\name = "hauptprogramm"
AddMapElement(template\headers(), "Datei")
AddElement(template\headers()\A())
template\headers()\A()\iconName = "Icon_Change"
template\headers()\A()\name = "Mandant wechseln"
template\headers()\A()\showIcon = #True
AddElement(template\headers()\A())
template\headers()\A()\iconName = "Icon_Exit"
template\headers()\A()\name = "Beenden"
template\headers()\A()\showIcon = #True
If CreateJSON(0)
InsertJSONStructure(JSONValue(0), @template, JsonMenuTemplate)
Debug ComposeJSON(0, #PB_JSON_PrettyPrint)
EndIf
I want to use ExtractJsonStructure() to get the JSON$ in an easy way to accessible data.
Any idea to solve this task?
Bernd