JsonCreateFromString(jsnString As String)

 

Creates a new JSON object and returns a pointer to it.

 

JSON is a lightweight data exchange format. It is described at http://json.org. It is based on the Javascript language.

The JSON Objects used in Seminar Pro contain a collection of key-value pairs.

 

(The internal JSON object is of Xojo type JSONItem [classic Xojo framework])

 

Once a JSON object exists, one can add or read child values with JsonSetValue or JsonGetValue.

 

Parameters:

 

Name

Type

Description

jsnString

String

A valid JSON String in curly brackets, with key/value pairs, separated by commas.

 

Example JSON String: {"subject":"title","content":"bodytext","recipientemail":"support@seminar.pro"}

 

Hint: Use double-quotes inside a string definition, in order to avoid a runtime-exception. See example below

 

Returns:

 

Type

Value

Description

Integer

Handle to JSON object

Returns a pointer to the created JSON object, of type Integer

Returns 0 or higher, if JSON object successfully has been created

 

If -1 is returned, then the creation failed

If -2 is returned, then a runtime exception occured

 

Available in:

 

WindowMain

WindowLink

YES

YES

 

Hint: You can find references to XojoScripts which make use of this function by sending the following SQL statement to the database:

Select id,GUID, ScriptName,ScriptCode from im_scripts where ScriptCode Like '%JsonCreateFromString%'

 

Example XojoScript:

 

// Using double-quotes inside of string, to escape exception

Dim js As String = _

"{""subject"":""title"",""content"":""bodytext"",""recipientemail"":""support@seminar.pro""}"

 

// Create new JSON Object from JSON string js

Dim handle As Integer = JsonCreatefromString(js)

 

// Retrieve email address from JSON object

If handle >= 0 Then

Dim email As String

email = JsonGetValue(handle,"recipientemail")

MsgBox("Email : " + email)

End If