Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Module = map[string]ugo.Object{ "Marshal": &ugo.Function{ Name: "Marshal", Value: stdlib.FuncPORO(marshalFunc), ValueEx: stdlib.FuncPOROEx(marshalFunc), }, "MarshalIndent": &ugo.Function{ Name: "MarshalIndent", Value: stdlib.FuncPOssRO(marshalIndentFunc), ValueEx: stdlib.FuncPOssROEx(marshalIndentFunc), }, "Indent": &ugo.Function{ Name: "Indent", Value: stdlib.FuncPb2ssRO(indentFunc), ValueEx: stdlib.FuncPb2ssROEx(indentFunc), }, "RawMessage": &ugo.Function{ Name: "RawMessage", Value: stdlib.FuncPb2RO(rawMessageFunc), ValueEx: stdlib.FuncPb2ROEx(rawMessageFunc), }, "Compact": &ugo.Function{ Name: "Compact", Value: stdlib.FuncPb2bRO(compactFunc), ValueEx: stdlib.FuncPb2bROEx(compactFunc), }, "Quote": &ugo.Function{ Name: "Quote", Value: stdlib.FuncPORO(quoteFunc), ValueEx: stdlib.FuncPOROEx(quoteFunc), }, "NoQuote": &ugo.Function{ Name: "NoQuote", Value: stdlib.FuncPORO(noQuoteFunc), ValueEx: stdlib.FuncPOROEx(noQuoteFunc), }, "NoEscape": &ugo.Function{ Name: "NoEscape", Value: stdlib.FuncPORO(noEscapeFunc), ValueEx: stdlib.FuncPOROEx(noEscapeFunc), }, "Unmarshal": &ugo.Function{ Name: "Unmarshal", Value: stdlib.FuncPb2RO(unmarshalFunc), ValueEx: stdlib.FuncPb2ROEx(unmarshalFunc), }, "Valid": &ugo.Function{ Name: "Valid", Value: stdlib.FuncPb2RO(validFunc), ValueEx: stdlib.FuncPb2ROEx(validFunc), }, }
Module represents json module.
Functions ¶
func MarshalIndent ¶
MarshalIndent is like Marshal but applies Indent to format the output. Each JSON element in the output will begin on a new line beginning with prefix followed by one or more copies of indent according to the indentation nesting.
Types ¶
type EncoderOptions ¶
EncoderOptions represents the encoding options (quote, html escape) to Marshal any Object.
func (*EncoderOptions) IndexSet ¶
func (eo *EncoderOptions) IndexSet(index, value ugo.Object) error
IndexSet implements ugo.Object interface.
func (*EncoderOptions) String ¶
func (eo *EncoderOptions) String() string
String implements ugo.Object interface.
func (*EncoderOptions) TypeName ¶
func (eo *EncoderOptions) TypeName() string
TypeName implements ugo.Object interface.
type Marshaler ¶
Marshaler is the interface implemented by types that can marshal themselves into valid JSON.
type MarshalerError ¶
type MarshalerError struct { Object ugo.Object Err error // contains filtered or unexported fields }
A MarshalerError represents an error from calling a MarshalJSON or MarshalText method.
func (*MarshalerError) Error ¶
func (e *MarshalerError) Error() string
func (*MarshalerError) Unwrap ¶
func (e *MarshalerError) Unwrap() error
Unwrap returns the underlying error.
type RawMessage ¶
type RawMessage struct { ugo.ObjectImpl Value []byte }
RawMessage represents raw encoded json message to directly use value of MarshalJSON without encoding.
func (*RawMessage) IndexSet ¶
func (rm *RawMessage) IndexSet(index, value ugo.Object) error
IndexSet implements ugo.Object interface.
func (*RawMessage) MarshalJSON ¶
func (rm *RawMessage) MarshalJSON() ([]byte, error)
MarshalJSON implements Marshaler interface and returns rm as the JSON encoding of rm.Value.
func (*RawMessage) String ¶
func (rm *RawMessage) String() string
String implements ugo.Object interface.
func (*RawMessage) TypeName ¶
func (rm *RawMessage) TypeName() string
TypeName implements ugo.Object interface.
type SyntaxError ¶
type SyntaxError struct { Offset int64 // error occurred after reading Offset bytes // contains filtered or unexported fields }
A SyntaxError is a description of a JSON syntax error.
func (*SyntaxError) Error ¶
func (e *SyntaxError) Error() string
type UnsupportedValueError ¶
An UnsupportedValueError is returned by Marshal when attempting to encode an unsupported value.
func (*UnsupportedValueError) Error ¶
func (e *UnsupportedValueError) Error() string