class

JsonWriter

@Js
class JsonWriter : Obj

Write Haystack data in JSON format.

constructors make

Wrap output stream

fields opts

methods valToStr

Get a value as a JSON string

writeGrid

Write the grid and return this

writeVal

Write any haystack value

flush

Flush the underlying output stream and return this

close

Close the underlying output stream

close Bool close()

Close the underlying output stream

flush This flush()

Flush the underlying output stream and return this

make new make(OutStream out, Dict? opts)

Wrap output stream. By default, the writer encodes JSON in the Haystack 4 (Hayson) format. Use the v3 option to encode JSON in the Haystack 3 format.

The following opts are supported:

  • v3 (Marker): write JSON in the Haystack 3 format
JsonWriter(out).writeVal(Etc.makeDict(["ts": DateTime.now])).close

JsonWriter(out, Etc.makeDict(["v3":Marker.val])).writeGrid(grid).close

opts Dict : opts

valToStr static Str valToStr(Obj? val)

Get a value as a JSON string.

writeGrid virtual This writeGrid(Grid grid)

Write the grid and return this

writeVal This writeVal(Obj? val)

Write any haystack value

Haxall 4.0.5 ∙ 24-Feb-2026 14:33 EST