ILiteGridTurboHelper Interface coclass LiteGridTurboHelper | Standalone JSON helper | No grid required

Standalone Usage

ILiteGridTurboHelper is a lightweight, non-visual COM object providing 18 JSON methods. It can be used from any VBA module or subroutine — no grid control instance is needed. It can also be used from Python (via pywin32), VB6, or any COM-compatible language.

Getting Started

Create the helper object using one of these patterns:

Registered Mode

Dim jh As Object
Set jh = CreateObject("LiteGridTurbo.LiteGridTurboHelper")

Registration-Free Mode

Dim jh As Object
LiteGridTurbo_CreateHelper jh

' Or using the bootstrap module:
Set jh = CreateJsonHelper()
Fail-Safe Contract

All mutation methods follow a fail-safe contract: they never throw errors to the caller. On any failure, they return the original JSON unchanged. All methods work without the grid control.

Key Difference

The grid control (ILiteGridTurboCtrl) exposes the same 18 methods prefixed with Json. Use ILiteGridTurboHelper when you need JSON parsing independently of the grid:

' ILiteGridTurboCtrl (grid instance — Json prefix)
Dim v As Variant
v = m_grid.JsonGetValue(json, "user.name")
json = m_grid.JsonSetValue(json, "age", 30)

' ILiteGridTurboHelper (standalone — no prefix)
v = jh.GetValue(json, "user.name")
json = jh.SetValue(json, "age", 30)
▶ Reading Methods 6 methods
MemberParametersReturnsDescription
GetValuejson As String, path As StringVariantExtract value by dot-notation path. Returns typed value (String, Long, Double, Boolean, or Null).
GetArrayLengthjson As String, path As StringLongCount elements in array at path.
GetArrayItemjson As String, path As String, index As LongStringGet single array element by zero-based index.
GetKeysjson As String, path As StringStringReturn all keys from object as JSON array.
IsValidjson As StringBooleanValidate JSON syntax.
Countjson As String, path As StringLongCount keys (object) or elements (array).

Reading Examples

Dim jh As Object
Set jh = CreateObject("LiteGridTurbo.LiteGridTurboHelper")

' GetValue — extract by dot-notation path
Dim v As Variant
v = jh.GetValue("{""name"":""Alice"",""age"":30}", "name")  ' "Alice"
v = jh.GetValue("{""a"":{""b"":5}}", "a.b")                 ' 5

' GetArrayLength — count array elements
Dim n As Long
n = jh.GetArrayLength("[1,2,3]", "")  ' 3

' GetArrayItem — get single element
Dim item As String
item = jh.GetArrayItem("[10,20,30]", "", 1)  ' "20"

' GetKeys — list all object keys
Dim keys As String
keys = jh.GetKeys("{""a"":1,""b"":2}", "")  ' ["a","b"]

' IsValid — validate syntax
If jh.IsValid(myJson) Then Debug.Print "Valid JSON"

' Count — count keys or elements
n = jh.Count("{""a"":1,""b"":2}", "")  ' 2
▶ Mutation Methods 8 methods
MemberParametersReturnsDescription
SetValuejson As String, path As String, value As VariantStringSet or create value at path. Auto-creates intermediate objects.
RemoveKeyjson As String, path As StringStringRemove a key or array element. Returns unchanged JSON if path not found.
Appendjson As String, path As String, value As VariantStringAppend value to array. Auto-creates array if missing.
Insertjson As String, path As String, index As Long, value As VariantStringInsert value at array index. Elements shift right.
Clearjson As String, path As StringStringEmpty an object or array without removing the key.
Mergejson1 As String, json2 As String, deep As BooleanStringMerge two JSON objects. deep=True for recursive merge.
Existsjson As String, path As StringBooleanCheck if a path exists in the JSON.
PrettyPrintjson As StringStringFormat JSON with 2-space indentation. Max 5 MB input.

Mutation Examples

Dim json As String

' SetValue — set or create values (auto-creates intermediates)
json = jh.SetValue("{}", "name", "Alice")
json = jh.SetValue(json, "address.city", "London")
' {"name":"Alice","address":{"city":"London"}}

' RemoveKey — remove a key
json = jh.RemoveKey("{""a"":1,""b"":2,""c"":3}", "b")
' {"a":1,"c":3}

' Append — add to array
json = jh.Append("{""tags"":[]}", "tags", "vba")
json = jh.Append(json, "tags", "com")
' {"tags":["vba","com"]}

' Insert — insert at array index
json = jh.Insert("[""a"",""c""]", "", 1, "b")
' ["a","b","c"]

' Clear — empty a container
json = jh.Clear("{""cache"":{""a"":1}}", "cache")
' {"cache":{}}

' Merge — combine two objects
Dim base As String
base = "{""name"":""Alice"",""prefs"":{""theme"":""dark""}}"
Dim overlay As String
overlay = "{""age"":30,""prefs"":{""lang"":""en""}}"
json = jh.Merge(base, overlay, True)
' Deep merge preserves prefs.theme

' Exists — check path
If jh.Exists(json, "user.email") Then Debug.Print "Has email"

' PrettyPrint — format JSON
Debug.Print jh.PrettyPrint("{""name"":""Alice"",""scores"":[95,88]}")
▶ Conversion Methods 4 methods
MemberParametersReturnsDescription
Serializevalue As VariantStringConvert any VBA value to JSON string.
ToArrayjson As StringVariantConvert JSON array-of-objects to 2D VBA array. Row 1 = headers, rows 2+ = typed data. 1-based indexing.
Flattenjson As StringStringFlatten nested JSON to dot-notation keys.
Unflattenjson As StringStringRebuild nested JSON from dot-notation keys.

Conversion Examples

' Serialize — VBA value to JSON
Debug.Print jh.Serialize(Array(1, 2, 3))        ' [1,2,3]
Debug.Print jh.Serialize("hello")               ' "hello"
Debug.Print jh.Serialize(True)                  ' true

' ToArray — JSON to 2D VBA array
Dim arr As Variant
arr = jh.ToArray("[{""name"":""Alice"",""age"":30},{""name"":""Bob"",""age"":25}]")
' arr(1,1) = "name"   arr(1,2) = "age"    <- headers
' arr(2,1) = "Alice"  arr(2,2) = 30       <- row 1
' arr(3,1) = "Bob"    arr(3,2) = 25       <- row 2

' Flatten — nested to dot-notation
Dim flat As String
flat = jh.Flatten("{""user"":{""name"":""Alice""}}")
' {"user.name":"Alice"}

' Unflatten — dot-notation to nested
Dim nested As String
nested = jh.Unflatten("{""user.name"":""Alice""}")
' {"user":{"name":"Alice"}}

Shared Methods Reference

All 18 ILiteGridTurboHelper methods are also available directly on the grid control (ILiteGridTurboCtrl) with a Json prefix. See the ILiteGridTurboCtrl reference for full documentation.

ILiteGridTurboHelperILiteGridTurboCtrl EquivalentCategory
GetValueJsonGetValueReading
GetArrayLengthJsonGetArrayLengthReading
GetArrayItemJsonGetArrayItemReading
GetKeysJsonGetKeysReading
IsValidJsonIsValidReading
CountJsonCountReading
SetValueJsonSetValueMutation
RemoveKeyJsonRemoveKeyMutation
AppendJsonAppendMutation
InsertJsonInsertMutation
ClearJsonClearMutation
MergeJsonMergeMutation
ExistsJsonExistsMutation
PrettyPrintJsonPrettyPrintMutation
SerializeJsonSerializeConversion
ToArrayJsonToArrayConversion
FlattenJsonFlattenConversion
UnflattenJsonUnflattenConversion