Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HexCodec ¶
type HexCodec struct{}
HexCodec encodes/decodes values to/from hex strings using the Canton MCMS format. This format is used for encoding operation parameters in Canton smart contracts.
Encoding format:
- uint8: 1 byte, hex-encoded
- uint32/int: 4 bytes, big-endian, hex-encoded
- int64: 8 bytes, big-endian, hex-encoded
- bool: 1 byte (00 or 01)
- text/string: uint8(len) + utf8 bytes
- list/slice: uint8(count) + items (encoded sequentially)
- struct: concatenate fields in order
type JsonCodec ¶
type JsonCodec struct {
// encodeNumericAsString controls whether numeric values are encoded as strings (true) or numbers (false)
// The latter might be useful for querying and mathematical operations, but can lose precision due to float point errors
EncodeNumericAsString bool
// encodeInt64AsString controls whether int64 values are encoded as strings (true) or numbers (false)
// The latter might be useful for querying and mathematical operations, but can lose precision,
// as numbers in some json implementations are backed by Double
EncodeInt64AsString bool
// excludeNullValuesInRecords controls whether fields with null values in records are excluded from JSON (true)
// or included with a null value (false)
ExcludeNullValuesInRecords bool
}
JsonCodec follows the transcode JsonCodec pattern for encoding DAML values to JSON
func NewJsonCodec ¶
func NewJsonCodec() *JsonCodec
NewJsonCodec creates a new JsonCodec with default settings following transcode patterns
func NewJsonCodecWithOptions ¶
func NewJsonCodecWithOptions(encodeNumericAsString, encodeInt64AsString, excludeNullValues bool) *JsonCodec
NewJsonCodecWithOptions creates a JsonCodec with custom options
Click to show internal directories.
Click to hide internal directories.