Documentation
¶
Overview ¶
Package rawjson provides a safe raw JSON byte type for workflow boundaries.
Motivation ¶
Go's json.RawMessage implements json.Marshaler and treats a non-nil empty slice as invalid JSON, returning: "json: error calling MarshalJSON for type json.RawMessage: 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 `json.RawMessage{}` 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 ¶
type Message json.RawMessage
Message is an opaque JSON value encoded as bytes.
Contract:
- Nil represents absence (preferred).
- Non-empty values must be valid JSON.
- 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 ¶
func (r Message) RawMessage() json.RawMessage
RawMessage returns the underlying value as json.RawMessage.
func (*Message) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
The decoder validates non-null JSON and normalizes null to nil.