RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Debug DrawingGPU Mesh StructsImGui FFIMath Structs (FFI)FFI C DefinitionsPID ControllersCSV LibraryDelay LineDequeDevelopment UtilitiesEvent ReferenceExtension SystemSignal FiltersGraph PathfindingUI BridgeInput Filter Constants2D Bilinear InterpolationIntrospectionJBeam Pretty PrinterJSON AST ParserSJSON ParserJSON Debug ParserJSON Pretty PrinterK-D Tree (2D Boxes)K-D Tree (3D)K-D Tree (3D)Lua SerializerC++/Lua BindingLua CoreLua ProfilerMath LibraryParticlesQuadtreeSettingsTCP ServerTimer SchedulerUtility Library

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API Referencecommon

JBeam Pretty Printer

Module defined in `lua/common/jbeamWriter.lua`. A specialized JSON pretty-printer for jbeam files that formats objects with indentation up to a configurable depth, then falls back to compact encoding

Module defined in lua/common/jbeamWriter.lua. A specialized JSON pretty-printer for jbeam files that formats objects with indentation up to a configurable depth, then falls back to compact encoding for deeper levels.


Exports

Functions

M.writeFile(filename, obj)

Writes a Lua table to a file as pretty-printed jbeam JSON with depth-limited formatting (max level 2).

  • Parameters:
    • filename - string - Output file path
    • obj - table - Data to serialize
  • Returns: boolean - True on success, false on failure

Internal Notes

  • Uses jsonEncodePrettyJbeam(v, lvl, numberPrecision, maxLevel) internally
  • When lvl > maxLevel, falls back to compact jsonEncode(v) for deeper structures
  • The components section at level 1 always gets full pretty-printing (maxLevel = 999)
  • Handles special cases: inf → 9e999, vec3 and quat cdata types → JSON objects
  • String escaping handles backslashes, newlines, tabs, quotes, carriage returns
  • Numbers use %.10g format by default, or fixed-precision when numberPrecision is specified

See Also

  • cdefDebugDraw Reference - Related reference
  • cdefGpuMesh Reference - Related reference
  • cdefImgui Reference - Related reference
  • Common Libraries Overview - Guide

Introspection

Module defined in `lua/common/introspection.lua`. Gathers method information from all globally registered classes and built-in modules for runtime reflection.

JSON AST Parser

Module defined in `lua/common/json-ast.lua`. A JSON/jbeam AST (Abstract Syntax Tree) parser that preserves formatting, comments, and whitespace. Used by the in-game jbeam editor for lossless round-tri

On this page

ExportsFunctionsM.writeFile(filename, obj)Internal NotesSee Also