GetElementByPointer method (NotesJSONNavigator – LotusScript)
Retrieves a NotesJSONElement using JSON Pointer syntax to identify the element.
Defined in
Syntax
Set el = jsnav.GetElementByPointer(pointer)
Parameters
pointerString. String in JSON Pointer notation.
A JSON Pointer is string that identifies the desired element. This JSON Pointer is a list of zero-to-many tokens, each prefixed by "/". Each token can be a string or a number.
Compared to using GetElementByName the JSON Pointer syntax used by GetElementByPointer can simplify working with more complex JSON objects.
For example, given a JSON:
{
"fruit" : ["apple", "banana"],
"price" : 1.99
}
The following JSON Pointers resolve this JSON as:
I. "/fruit" → [ "apple", "banana" ]
II. "/fruit/0" → "apple"
III. "/fruit/1" → "banana"
IV. "/price" → 1.99
Note that, an empty JSON Pointer "" (zero token) resolves to the whole JSON.
[SuppressErrors]Return value
Returns NotesJSONElement that corresponds to the JSON pointer. If pointer is empty string, return whole document in JSONNavigator.
Example
Dim jsnav As NotesJSONNavigator
Set jsnav = session.CreateJSONNavigator(|{"test":"A string"}|)
Set el = jsnav.GetElementByPointer("/test")Dim jsnav As NotesJSONNavigator
Set jsnav = session.CreateJSONNavigator(|{"test":"A string"}|)
Set el = jsnav.Getelementbypointer("/test1", True)
If el Is Nothing Then
MessageBox("Elemenet not found")
End IfDim session As New NotesSession
Dim jsnav As NotesJSONNavigator
Dim el As NotesJSONElement
Dim subel As NotesJSONElement
Set jsnav = session.CreateJSONNavigator(|{"test1":"A string 1", "test2":"A String2"}|)
Set el = jsnav.GetElementByPointer("") 'Element value now {"test1":"A string 1", "test2":"A String2"}
Set subel = el.value.GetFirstElement()
while Not (subel is Nothing)
MessageBox(subel.value)
Set subel = el.value.GetNextElement()
WendSub Initialize
Dim session As New NotesSession
Dim el As NotesJSONElement
Dim jsnav As NotesJSONNavigator
Set jsnav = session.CreateJSONNavigator(|{"fruit" : ["apple", "banana"],"price" : 1.99}|)
Set el = jsnav.GetElementByPointer("/fruit/1") 'banana
MessageBox(el.value)
End Sub