Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Marshal ¶
Marshal will act the same way as json.Marshal, except it will choose the ffjson marshal function before falling back to using json.Marshal. Using this function will bypass the internal copying and parsing the json library normally does, which greatly speeds up encoding time. It is ok to call this function even if no ffjson code has been generated for the data type you pass in the interface.
func MarshalFast ¶
MarshalFast will marshal the data if fast marshal is available. This function can be used if you want to be sure the fast marshal is used or in testing. If you would like to have fallback to encoding/json you can use the Marshal() method.
func Pool ¶
func Pool(b []byte)
Send a buffer to the Pool to reuse for other instances.
On servers where you have a lot of concurrent encoding going on, you can hand back the byte buffer you get marshalling once you are done using it.
You may no longer utilize the content of the buffer, since it may be used by other goroutines.
func Unmarshal ¶
Unmarshal will act the same way as json.Unmarshal, except it will choose the ffjson unmarshal function before falling back to using json.Unmarshal. The overhead of unmarshal is lower than on Marshal, however this should still provide a speedup for your encoding. It is ok to call this function even if no ffjson code has been generated for the data type you pass in the interface.
func UnmarshalFast ¶
UnmarshalFast will unmarshal the data if fast marshall is available. This function can be used if you want to be sure the fast unmarshal is used or in testing. If you would like to have fallback to encoding/json you can use the Unmarshal() method.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
This is a reusable decoder. This should not be used by more than one goroutine at the time.
func (*Decoder) DecodeFast ¶
DecodeFast will unmarshal the data if fast unmarshal is available. This function can be used if you want to be sure the fast unmarshal is used or in testing. If you would like to have fallback to encoding/json you can use the regular Decode() method.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
This is a reusable encoder. It allows to encode many objects to a single writer. This should not be used by more than one goroutine at the time.
func NewEncoder ¶
NewEncoder returns a reusable Encoder. Output will be written to the supplied writer.
func (*Encoder) Encode ¶
Encode the data in the supplied value to the stream given on creation. When the function returns the output has been written to the stream.
func (*Encoder) EncodeFast ¶
EncodeFast will unmarshal the data if fast marshall is available. This function can be used if you want to be sure the fast marshal is used or in testing. If you would like to have fallback to encoding/json you can use the regular Encode() method.
func (*Encoder) SetEscapeHTML ¶
SetEscapeHTML specifies whether problematic HTML characters should be escaped inside JSON quoted strings. The default behavior is to escape &, <, and > to \u0026, \u003c, and \u003e to avoid certain safety problems that can arise when embedding JSON in HTML.
In non-HTML settings where the escaping interferes with the readability of the output, SetEscapeHTML(false) disables this behavior.