GetNthElement method (NotesJSONNavigator – LotusScript)

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

Defined in

NotesJSONNavigator

Syntax

Set el = jsnav.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 element when the index is bigger than max element index of JSON Navigator.
Note: This parameter is new with release 14.5.1.

Return value

Returns NotesJSONElement that corresponds to the first element in the JSON string. If not use SuppressError = True, will raise “Index is out of range” error when pass in Index bigger than max element index of NotesJSON Navigator.

Example

The following code returns an element with the name "element2" and a value of "Another string".
Dim jsnav As NotesJSONNavigator
	
Set jsnav = s.CreateJSONNavigator(
|{ "element1" : "A string", "element2" : "Another string", "element3 ": "Third string" }|)	

Set el = jsnav.GetNthElement(2)
The following code returns a null element when using index bigger than max element index
Dim session As New NotesSession
Dim jsnav As NotesJSONNavigator
Dim el As NotesJSONElement
Set jsnav = session.CreateJSONNavigator(|{"test1":"A string 1", "test2":"A String2"}|) 
Set el = jsnav.Getnthelement(3, True)
If el Is Nothing Then
	MessageBox("Index out of range")
End If