JsonAppend(jsnHandle As Integer, jsnHandleToAppend As Integer) 

 

Append a new JSONItem object to an array of JSONItems.

 

In the example script below we create an sms recipients list as array of key/value pairs (JSON objects).

Each recipient is added by using JsonAppend method.

 

The resulting JSON string looks like this:

 

Ein Bild, das Text enthält.

Automatisch generierte Beschreibung

 

For a real world example on how to make use of gatewayapi.com follow this link:

How to send sms via gatewayapi.com

 

 

Parameters:

 

Name

Type

Description

jsnHandle

Integer

Identification number for existing JSON object, instantiated with the JSONCreate method

jsnHandleToAppend

Integer

Identification number for existing JSON object, instantiated with the JSONCreate method.

 

This JSON object will be added to the first one

 

 

WindowMain

WindowLink

YES

NO

 

 

Example XojoScript:

 

// Define upper limit

Dim numRecs As Integer = 3

 

// Create new JSON objects

Dim handleContent      As Integer = JsonCreate

Dim handleRecipients   As Integer = JsonCreate

Dim handleOneRecipient As Integer = JsonCreate

Dim id As String

 

JsonSetValue(handleContent,"message", "sms text")

JsonSetValue(handleContent,"sender", "NWS-SMS")

 

If handleContent >= 0 And handleRecipients >=0 And handleOneRecipient >=0 Then

 

For i As Integer = 0 To numRecs-1

 

// Add recipient

handleOneRecipient = JsonCreate

JsonSetValue(handleOneRecipient,"msisdn","4176210500"+Str(i))

 

// Add this new recipient to Array of recipients

JsonAppend(handleRecipients,handleOneRecipient)

 

Next

 

// Add whole recipients Array to Json Content object

JsonSetValueArray(handleContent,"recipients",handleRecipients)

 

// Convert JSON object to a string

Dim js As String = JsonToString(handleContent)

 

MsgBox(js)

 

// Release JSON Objects

JsonclearAll

End If