JsonGetValueInteger(jsnHandle As Integer, key As String) As Integer

 

Retrieves the integer value of a JSON child element.

 

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])

 

Parameters:

 

Name

Type

Description

jsnHandle

Integer

A pointer to the created JSON object, of type Integer

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

 

If jsnHandle is -1, then the creation failed

If jsnHandle is -2, then a runtime exception occurred

key

String

The exact name of the key for which its value will be returned.

The string "key not found" is returned, if a wrong key is used.

 

Returns:

 

Type

Value

Description

Integer

value of JSON child element

The JSON Objects used in Seminar Pro contain a collection of name-value pairs. You pass in the the key and the corresponding value is returned.

 

 

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 '%JsonGetValueInteger%'

 

Example XojoScript:

 

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

Dim js As String = "{""number"":108,""email"":""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 num As Integer

num = JsonGetValueinteger(handle,"number")

MsgBox("Number : " + Str(num))

End If