GetElementByName method (NotesJSONObject - LotusScript)

Returns a JSON object represented by "name".

Defined in

NotesJSONObject

Syntax

Set el = obj.Getelementbyname("name")

Parameters

name

String.

[SuppressErrors]

Boolean. Optional. If True, suppress “JSON Element not found error” and return Null element when element not found.

Note: This parameter is new with release 14.5.1.

Return value

JSON object. If the JSONElement is not found and not using SuppressError = True, the following error is thrown: 4843 - JSON Element not found.

Example

The following example retrieves the object named "object1" and displays a message box with the text "object1 = inner1:innerval1".
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.Getelementbyname("object1")
Set el = el.value.GetelementByName("inner1")
MsgBox "object1 = " & CStr(el.Name) & ":" & CStr(el.Value)
The following example get a null element and not suppress error “Element Not Found” when no element found.
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.Getelementbyname("object1")
Set el = el.value.GetelementByName("inner4")
If el Is Nothing Then
	MessageBox("Element not found")
End If