Color scheme: Light
You are here: start » en » Documentation » Microsoft Access development tools » WKL Office JSON » WKL Office JSON API reference » JElement

JElement

JElement class

Signature

Dim myJElement As JElement

Summary

A JSON object: key–value pairs in document order.

Parameters

None

Remarks

Keys are case-sensitive. A duplicate key in loaded JSON keeps the last value, as most JSON parsers do.

Not created directly; returned by other members of the library.

MemberKindSummary
`Keys`PropertyReturns all keys in document order.
`HasKey`MethodTells whether a key exists.
`SetValue`MethodSets the value of a key, new or replacing, and returns its node.
`AddElement`MethodAdds a new, empty object under a key.
`AddArray`MethodAdds a new, empty array under a key.
`RemoveKey`MethodRemoves a key and its value.
`Clear`MethodRemoves all keys.

Code example

None

Inheritance

JElement inherits every member of `JNode`; inherited members are described on the base class's page.

Keys property

Signature

Property Get Keys() As Variant

Summary

Returns all keys in document order.

Parameters

None

Property value: Variant – A String array; an array without elements for an empty object.

Remarks

Read-only.

Code example

None

Inheritance

Declared by JElement.

HasKey method

Signature

Function HasKey(ByVal Key As String) As Boolean

Summary

Tells whether a key exists.

Parameters

NameTypeOptionalDefaultDescription
KeyStringNo–The key; case-sensitive.

Return value: Boolean – True when the key exists.

Remarks

None

Code example

None

Inheritance

Declared by JElement.

SetValue method

Signature

Function SetValue(ByVal Key As String, ByVal Value As Variant) As JNode

Summary

Sets the value of a key, new or replacing, and returns its node.

Parameters

NameTypeOptionalDefaultDescription
KeyStringNo–The key.
ValueVariantNo–The value (the types of `JNode.Value`), or a node to insert.

Return value: `JNode` – The node that holds the value.

Remarks

A detached node (new, cloned, or removed) is inserted itself: later changes through the VBA variable show in the tree. A node that is already attached, or that belongs to another document, is copied. Inserting a node into its own subtree raises jeInvalidOperation.

Values that have no JSON form (objects other than nodes, arrays with more than one dimension, Scripting.Dictionary, Collection) raise jeUnsupportedValue.

Code example

root.SetValue "customer", "Miller"
root.SetValue "date", Date          ' written as ISO 8601
root.SetValue "note", Null

Inheritance

Declared by JElement.

AddElement method

Signature

Function AddElement(ByVal Key As String) As JElement

Summary

Adds a new, empty object under a key.

Parameters

NameTypeOptionalDefaultDescription
KeyStringNo–The key; an existing key is replaced.

Return value: `JElement` – The new `JElement`.

Remarks

None

Code example

None

Inheritance

Declared by JElement.

AddArray method

Signature

Function AddArray(ByVal Key As String) As JArray

Summary

Adds a new, empty array under a key.

Parameters

NameTypeOptionalDefaultDescription
KeyStringNo–The key; an existing key is replaced.

Return value: `JArray` – The new `JArray`.

Remarks

None

Code example

None

Inheritance

Declared by JElement.

RemoveKey method

Signature

Function RemoveKey(ByVal Key As String) As Boolean

Summary

Removes a key and its value.

Parameters

NameTypeOptionalDefaultDescription
KeyStringNo–The key.

Return value: Boolean – True when the key existed.

Remarks

None

Code example

None

Inheritance

Declared by JElement.

Clear method

Signature

Sub Clear()

Summary

Removes all keys.

Parameters

None

Remarks

None

Code example

None

Inheritance

Declared by JElement.

en/wiki/msaccess/json/api-reference/jelement.txt · Last modified: by Wolfgang van der Stille