Test JSON Files Syntax
Validates the syntax of every JSON, JBeam, and PC file in the game by attempting to decode each.
Validates the syntax of every JSON, JBeam, and PC file in the game by attempting to decode each.
Overview
util_testJSONFilesSyntax is a validation utility that scans the entire filesystem for .jbeam, .pc, and .json files and decodes each with jsonDebug.decode(). Parse errors and warnings are logged. This is used in CI/QA to catch malformed data files.
Extension path: lua/ge/extensions/util/testJSONFilesSyntax.lua
Exports (M)
| Function | Signature | Description |
|---|---|---|
onExtensionLoaded | () | Scans all JSON/JBeam/PC files and validates their syntax. |
Internals
Validation
Uses jsonDebug module (a stricter JSON decoder that returns warnings):
local state, data, warnings = xpcall(
function() return jsonDebug.decode(content, context) end,
debug.traceback
)- Errors: Logged at
'E'level with the file path and error message. - Warnings: Logged at
'W'level (e.g., trailing commas, duplicate keys).
File Discovery
FS:findFiles('/', "*.jbeam\t*.pc\t*.json", -1, true, false)Scans recursively from root, including all mod content.
How It Works
- Extension loads (typically via CLI).
onExtensionLoadedfinds all matching files.- Each file is read and decoded.
- Errors and warnings are logged to console.
Lua Examples
-- Run as a batch validation tool:
-- beamng.exe -onLevelLoad_ext "util/testJSONFilesSyntax"
-- Or load manually to validate all files:
extensions.load("util/testJSONFilesSyntax")
-- Check console output for errors/warningsAdditional Exports
M.onExtensionLoaded- (undocumented)
Test Extension Proxies
Demonstration/test extension showing how to use `newExtensionProxy` to fan out extension hooks to multiple object instances.
util/vehicleRopeDebug - Rope Physics Debug UI
Reference for `extensions/util/vehicleRopeDebug.lua`. Provides an ImGui debug sandbox for visualizing and editing rope physics parameters on the current vehicle.