Skip to main content
Version: Next

Compact Format (stream / lite / json / lua)

Since v4.0, non-atomic fields can declare cell format on the field name (not on ##type):

pos#format=lite
cost#format=json

Four formats

formatMeaningTypical cell
stream (default)Stream; blanks often skippedWith sep: 1,2,3
liteBraces; usually no field names{1.0,2.0,3.0}
jsonJSON inside the cell{"x":1,"y":2}
luaLua table inside the cell{x=1,y=2}

Full lite example

<bean name="Vec3">
<var name="x" type="float"/>
<var name="y" type="float"/>
<var name="z" type="float"/>
</bean>
<bean name="Shape"/>
<bean name="Circle" parent="Shape">
<var name="radius" type="float"/>
</bean>
##varidpos#format=liteshape#format=litetags#format=lite
##typeintVec3Shapelist,int
1{1,2,3}{Circle,1.5}{10,20,30}
2{0,0,1}{Circle,2.0}{}

Key points:

RuleNotes
bean / containerUse {...}; nesting allowed {1,xxxx,{1,2,3}}
Polymorphism{TypeName,field1,field2,...}; when the type is Shape (not Shape?) you must give a concrete subclass; cannot write null
Nullable bean (T?)Only then may you write null; do not write {null}
DefaultsDoes not support column mode’s “omit field → use default”
WhitespaceWhitespace similar to HTML is stripped

json cell example

##varidpos#format=jsonshape#format=json
##typeintVec3Shape
1{"x":1,"y":2,"z":3}{"$type":"Circle","radius":1.5}

Good when matching JSON fragments exported by external tools.

lua cell example

##varidpos#format=lua
##typeintVec3
1{x=1,y=2,z=3}

For polymorphic fields the type key is generally _type_ (same as file-based lua data sources).

Choosing among sep / column mode

ScenarioSuggestion
Designers want to read each column at a glanceColumns + merged cells
Short vectors, small structssep or lite
Existing JSON fragmentsjson
Very long lists that would explode columnslite/json, or multi-row lists

Common pitfalls

  • Putting #format=lite on ##type → no effect; put it on the field name.
  • Writing {null} in lite for nullable → write null instead.
  • Assuming lite can omit middle fields for defaults → it cannot; write them all or use column mode.