Documentation
¶
Overview ¶
Package rawjson provides a safe raw JSON byte type for workflow boundaries.
Motivation ¶
Go's jsontext.Value implements json.Marshaler and treats a non-nil empty slice as invalid JSON, returning: "json: error calling MarshalJSON for type jsontext.Value: unexpected end of JSON input".
In this runtime, raw JSON byte fields are intentionally used at workflow and activity boundaries (tool payloads/results, hook envelopes, server-data sidecars). A single accidental `jsontext.Value{}` or `[]byte{}` assignment can therefore crash workflow encoding.
Message eliminates that failure mode by normalizing empty/whitespace payloads to JSON null during marshaling while still validating non-empty payloads.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Message ¶
Message is an opaque JSON value encoded as bytes.
Contract:
- Nil represents absence (preferred).
- Non-empty values must be valid RFC 7493 JSON: UTF-8 encoded, with valid Unicode and unique names in every object.
- Empty/whitespace-only values are normalized to JSON null during marshaling to avoid runtime encoding failures at workflow boundaries.
func (Message) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
This method never returns an "unexpected end of JSON input" error for empty slices; empty/whitespace is encoded as JSON null.
func (Message) RawMessage ¶
RawMessage returns the underlying value as jsontext.Value.
func (*Message) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
The decoder validates non-null JSON and normalizes null to nil.