github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/protocol/json.go (about)

     1  /* For license and copyright information please see LEGAL file in repository */
     2  
     3  package protocol
     4  
     5  // JSON is the interface that must implement by any struct to be a JSON object.
     6  // Standards by https://www.json.org/json-en.html
     7  type JSON interface {
     8  	// ToJSON encode the struct pointer to JSON format
     9  	// actually payload is a byte slice buffer interface but due to prevent unnecessary memory allocation use simple []byte
    10  	ToJSON(payload []byte) []byte
    11  	// FromJSON decode JSON to the struct pointer
    12  	// actually payload is a byte slice buffer interface but due to prevent unnecessary memory allocation use simple []byte
    13  	FromJSON(payload []byte) (err Error)
    14  
    15  	// LenAsJSON return whole calculated length of JSON encoded of the struct
    16  	LenAsJSON() int
    17  }