Example: /Util/JSON/JSON

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/Util/JSON/JSON


Required plugins for this example: MBS Util Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Util/JSON/JSON

This example is the version from Sat, 2nd Aug 2013.

Project "JSON.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control EditField1 Inherits TextArea
ControlInstance EditField1 Inherits TextArea
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() dim j as new JSONMBS(EditField1.text) Add j EditField2.text = (j.toString) End EventHandler
End Control
Control EditField2 Inherits TextArea
ControlInstance EditField2 Inherits TextArea
End Control
Control list Inherits Listbox
ControlInstance list Inherits Listbox
EventHandler Sub ExpandRow(row As Integer) dim j as JSONMBS = List.CellTag(row,0) dim c as JSONMBS = j.ChildNode while c<>Nil add c c=c.NextNode wend End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() dim j as JSONMBS = BuildTest Add j EditField2.text = (j.toString) End EventHandler
End Control
Private Sub Add(j as JSONMBS) dim t as string Select case j.Type case j.kTypeArray t="Array: " case j.kTypeNumber t="Number: " case j.kTypeObject t="Object: " case j.kTypeString t="String: " case j.kTypeTrue t="True" case j.kTypeFalse t="False" case j.kTypeNull t="Null" end Select if j.ChildNode<>nil then List.AddFolder t+j.ValueString else List.AddRow t+j.ValueString end if List.CellTag(List.LastIndex,0)=j End Sub
Private Function BuildTest() As JSONMBS dim j as JSONMBS = JSONMBS.NewObjectNode j.AddItemToObject "String Node", JSONMBS.NewStringNode("Hello World") j.AddItemToObject "False Node", JSONMBS.NewFalseNode j.AddItemToObject "True Node", JSONMBS.NewTrueNode j.AddItemToObject "Null Node", JSONMBS.NewNullNode dim o as JSONMBS = JSONMBS.NewObjectNode o.AddItemToObject "x", JSONMBS.NewStringNode("a") o.AddItemToObject "y", JSONMBS.NewStringNode("b") o.AddItemToObject "z", JSONMBS.NewStringNode("c") j.AddItemToObject "Object Node", o j.AddItemToObject "Number Node", JSONMBS.NewNumberNode(8) dim a as JSONMBS = JSONMBS.NewArrayNode for i as integer = 1 to 10 a.AddItemToArray JSONMBS.NewNumberNode((i)) next j.AddItemToObject "Array Node",a Return j End Function
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

See also:

The items on this page are in the following plugins: MBS Util Plugin.


💬 Ask a question or report a problem