Documentation
¶
Overview ¶
Package jsonout writes JSON documents the way Ruby's JSON.generate writes them: members in the order the caller states, no whitespace, and Ruby's escape set for strings.
It exists because every structured CLI surface is compared byte for byte against the Ruby oracle, and encoding/json cannot produce those bytes: Go sorts map keys, escapes `<`, `>`, `&`, U+2028 and U+2029, and spells floats with its own shortest-round-trip algorithm. The record package already owns the Ruby-compatible primitives (string escaping, number spelling, whole-value emission); this package is the ordered-object writer built on top of them.
Index ¶
- type Writer
- func (w *Writer) BeginArray()
- func (w *Writer) BeginObject()
- func (w *Writer) Bool(value bool)
- func (w *Writer) Bytes() []byte
- func (w *Writer) EndArray()
- func (w *Writer) EndObject()
- func (w *Writer) Err() error
- func (w *Writer) Int(value int)
- func (w *Writer) Key(name string)
- func (w *Writer) KeyBool(name string, value bool)
- func (w *Writer) KeyInt(name string, value int)
- func (w *Writer) KeyNull(name string)
- func (w *Writer) KeyStr(name, value string)
- func (w *Writer) KeyStrOrNull(name, value string)
- func (w *Writer) Null()
- func (w *Writer) Raw(raw json.RawMessage)
- func (w *Writer) Str(value string)
- func (w *Writer) StrOrNull(value string)
- func (w *Writer) String() string
- func (w *Writer) Strings(values []string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer accumulates one JSON document. Members appear in call order.
func (*Writer) KeyStr ¶
KeyStr, KeyStrOrNull, KeyBool and KeyInt are the one-call spellings of the overwhelmingly common key/value pair.
func (*Writer) KeyStrOrNull ¶
func (*Writer) Raw ¶
func (w *Writer) Raw(raw json.RawMessage)
Raw writes an already-parsed JSON value with Ruby's spelling. A nil or empty value is `null`, which is how an absent record field reads.