class
UCL::Encoder
- UCL::Encoder
- Reference
- Object
Overview
Serializes a Crystal object into a UCL/JSON/YAML/MsgPack string by building
a libucl object tree and emitting it. Backs UCL.dump.
Defined in:
ucl/encoder.crConstant Summary
-
DEFAULT_EMITTER =
"config" -
Emitter used when none is given:
"config"(UCL output). -
EMITTERS =
{"json" => UCL::LibUCL::Emitters::UCL_EMIT_JSON, "json_compact" => UCL::LibUCL::Emitters::UCL_EMIT_JSON_COMPACT, "config" => UCL::LibUCL::Emitters::UCL_EMIT_CONFIG, "yaml" => UCL::LibUCL::Emitters::UCL_EMIT_YAML, "msgpack" => UCL::LibUCL::Emitters::UCL_EMIT_MSGPACK} -
Maps the emitter names accepted by
.encodeto their libucl counterparts.
Class Method Summary
-
.encode(object, emit_type : String | Emitter = DEFAULT_EMITTER) : String
Serializes object using emit_type, a typed
UCL::Emitteror one of the legacy string keys ofEMITTERS.
Class Method Detail
Serializes object using emit_type, a typed UCL::Emitter or one of the
legacy string keys of EMITTERS.
Raises UCL::Error::EncoderError for an unknown string emit_type, and
UCL::Error::TypeError for a non-String hash key or an unsupported
value type.