For time values, the encoder doesn't invoke MarshalJSON or MarshalText, but use the time.AppendFormat function instead, and write the result to the stream. The time.Time and time.Duration types are handled natively. Please note that these might evolve with future versions of the package. Differences with encoding/jsonĪll notable differences with the standard library behavior are listed below. An instruction is a function or a closure, that have all the information required to read the data from memory using unsafe operations (pointer type conversion, arithmetic.) during the instruction set execution. When marshaling a value, a set of instructions is recursively generated for its type, which defines how to iteratively encode it. The main concept of Jettison consists of using pre-build instructions-set to reduce the cost of using the reflect package at runtime. As such, most of the tests compare their output against it to guarantee that. The package aims to have a behavior similar to that of the standard library for all types encoding and struct tags, meaning that the documentation of the json.Marshal function is applicable for Jettison, with a few exceptions described in this section. The drawback to this approach requires to instantiate an instruction-set once for each type that needs to be marshaled, but that is overcomed with a package cache. Unlike the latter, Jettison does not use reflection during marshaling, but only once to create the instruction set for a given type ahead of time. The goal of Jettision is to take up the idea introduced by the bet365/jingo package and build a fully-featured JSON encoder around it, that comply with the behavior of the encoding/json package. Extensive testsuite that compares its output against encoding/json.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |