@gwigz/slua

Tag Format

Complete reference for SLua tagged JSON tags, tight mode, and null/nil mapping

Tag Reference

TagTypeNormal formatTight format
!vVector!v<x,y,z>!vx,y,z (zeros omitted)
!qQuaternion!q<x,y,z,w>!qx,y,z,w (zeros omitted)
!uUUID!uXXXX-XXXX-... (36 chars)!u + base64 (22 chars)
!dBuffer!d + base64same
!fFloat!f3.14same
!bBoolean!b1 / !b0same
!nNil!nsame
!!Escaped !!!textsame

Tight Mode

Pass { tight: true } to slencode (or codec.slencode) to produce more compact output. In tight mode:

  • Vector and quaternion zero components are omitted (e.g. !v,,1 for (0, 0, 1))
  • UUIDs are base64-encoded (22 chars instead of 36)

Tight mode output can always be decoded by the standard sldecode.

JS ↔ Lua Null Mapping

JavaScriptLuaJSON wire
nulllljson.nullnull
undefinednil"!n"

null in JavaScript maps to the special lljson.null sentinel in Lua and serialises as JSON null. undefined maps to Lua nil and serialises as the "!n" tag.

On this page