NotesJsonNavigator.getNthElement does not obey boundries
I stumbled upon an issue with NotesJsonNavigator getNthElement(index) method.
It looks like there is no boundry check, which leads to some inconsitent behaviour and unpredictable results.
Here is the code that I used in my test.
%REM
Sub testJsonNavGetNthElement
%END REM
Public Sub testJsonNavGetNthElement
Dim s As New NotesSession
Dim jsnav As NotesJSONNavigator
Dim el As NotesJSONElement
Set jsnav = s.CreateJSONNavigator(|{ "element1" : "value 1", "element2" : "value 2", "element3 ": "value 3" }|)
Set el = jsnav.GetNthElement(0)
Stop
Set el = jsnav.GetNthElement(1)
Stop
Set el = jsnav.GetNthElement(2)
Stop
Set el = jsnav.GetNthElement(3)
Stop
Set el = jsnav.GetNthElement(1000)
Stop
End Sub
The issue occurs with index < 1 and > upper bound of the array.
Index 0 AND index 1 both return the same value; “value 1“.
Index 1000 returns NULL or nothing.
This is not the expected behaviour. At least I would expect some “out of bounds” error.Also, it is not clear for me what the base for the index is. Do we start counting at 0 or do we start with 1 ?
According to the documentation, the index is 1-based.