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)
Mutation Methods
8 methods
| Member | Parameters | Returns | Description |
|---|---|---|---|
| SetValue | json As String, path As String, value As Variant | String | Set or create value at path. Auto-creates intermediate objects. |
| RemoveKey | json As String, path As String | String | Remove a key or array element. Returns unchanged JSON if path not found. |
| Append | json As String, path As String, value As Variant | String | Append value to array. Auto-creates array if missing. |
| Insert | json As String, path As String, index As Long, value As Variant | String | Insert value at array index. Elements shift right. |
| Clear | json As String, path As String | String | Empty an object or array without removing the key. |
| Merge | json1 As String, json2 As String, deep As Boolean | String | Merge two JSON objects. deep=True for recursive merge. |
| Exists | json As String, path As String | Boolean | Check if a path exists in the JSON. |
| PrettyPrint | json As String | String | Format 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
| Member | Parameters | Returns | Description |
|---|---|---|---|
| Serialize | value As Variant | String | Convert any VBA value to JSON string. |
| ToArray | json As String | Variant | Convert JSON array-of-objects to 2D VBA array. Row 1 = headers, rows 2+ = typed data. 1-based indexing. |
| Flatten | json As String | String | Flatten nested JSON to dot-notation keys. |
| Unflatten | json As String | String | Rebuild 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"}}