GetNthElement method (NotesJSONObject - LotusScript)

Retrieves the element from the JSON object represented by the provided index.

Defined in

NotesJSONObject

Syntax

Set el = obj.Getnthelement(Index)

Parameters

Index

Long.

1-based index that identifies which element to return.

[SuppressErrors]

Boolean. Optional. If True, suppress error “Index is out of range” and return Null element when the index is bigger than max element index of NOTESJSON Object.

Note: This parameter is new with release 14.5.1.

Return value

The next NotesJSONElement in the object.

Example

The following example retrieves the object named "object3" and displays a message box with the text "Nth (3)= inner3:innerval3".
Dim s As New NotesSession
Dim jsnav As NotesJSONNavigator
Dim el As NotesJSONElement
Dim obj As NotesJSONObject

Set jsnav = s.CreateJSONNavigator(|{"objects":{"object1": {"inner1":"innerval1"},"object2": {"inner2":"innverval2"}, "object3": {"inner3":"innverval3"}}}|)
Set el = jsnav.Getfirstelement()
Set obj = el.Value
Set el = obj.GetNthElement(3)
Set obj = el.value
Set el = obj.GetElementByName("inner3")
MsgBox "Nth (3) object = " & CStr(el.Name) & ":" & CStr(el.Value)
The following example returns Null element, not raise “Element not found” error, when pass in index bigger than max element index of NotesJSON object.
Dim s As New NotesSession
Dim jsnav As NotesJSONNavigator
Dim el As NotesJSONElement
Dim obj As NotesJSONObject

Set jsnav = s.CreateJSONNavigator(|{"objects":{"object1": {"inner1":"innerval1"},"object2": {"inner2":"innverval2"}, "object3": {"inner3":"innverval3"}}}|)
Set el = jsnav.Getfirstelement()
Set obj = el.Value
Set el = obj.GetNthElement(4, True)
If el Is Nothing Then
	MessageBox("Index out of range")
End If