B4J Programming Press on the image to return to the main documentation page.

Json

List of types:

JSONGenerator
JSONParser

JSONGenerator

This object generates JSON strings.
It can be initialized with a Map or a List. Both can contain other Maps or Lists.
See the JSON tutorial.

Events:

None

Members:


  Initialize (Map As Map)

  Initialize2 (List As List)

  ToPrettyString (Indent As Int) As String

  ToString As String

Members description:

Initialize (Map As Map)
Initializes the object with the given Map.
Initialize2 (List As List)
Initializes the object with the given List.
ToPrettyString (Indent As Int) As String
Creates a JSON string from the initialized object.
The string will be indented and easier for reading.
Note that the string created is a valid JSON string.
Indent - Number of spaces to add to each level.
ToString As String
Creates a JSON string from the initialized object.
This string does not include any extra whitespace.

JSONParser

Parses JSON formatted strings: Description of JSON.
JSON objects are converted to Maps and JSON arrays are converted to Lists.
After initializing the object you will usually call NextObject to get a single Map object.
If the JSON string top level value is an array you should call NextArray.
Afterward you should work with the Map or List and fetch the required data.
See the JSON tutorial.
Typical code:
Dim JSON As JSONParser
Dim Map1 As Map
JSON.Initialize(File.ReadString(File.DirAssets, "example.json")) 'Read the text from a file.
Map1 = JSON.NextObject

Events:

None

Members:


  Initialize (Text As String)

  IsInitialized As Boolean

  NextArray As List

  NextObject As Map

  NextValue As Object

Members description:

Initialize (Text As String)
Initializes the object and sets the text that will be parsed.
IsInitialized As Boolean
NextArray As List
Parses the text assuming that the top level value is an array.
NextObject As Map
Parses the text assuming that the top level value is an object.
NextValue As Object
Parses the text assuming that the top level value is a simple value.
Top