Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for newEncodeState (0.12 sec)

  1. src/encoding/json/stream.go

    //
    // See the documentation for [Marshal] for details about the
    // conversion of Go values to JSON.
    func (enc *Encoder) Encode(v any) error {
    	if enc.err != nil {
    		return enc.err
    	}
    
    	e := newEncodeState()
    	defer encodeStatePool.Put(e)
    
    	err := e.marshal(v, encOpts{escapeHTML: enc.escapeHTML})
    	if err != nil {
    		return err
    	}
    
    	// Terminate each value with a newline.
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Sep 08 19:04:28 UTC 2023
    - 12.9K bytes
    - Viewed (0)
  2. src/encoding/json/encode.go

    //
    // JSON cannot represent cyclic data structures and Marshal does not
    // handle them. Passing cyclic structures to Marshal will result in
    // an error.
    func Marshal(v any) ([]byte, error) {
    	e := newEncodeState()
    	defer encodeStatePool.Put(e)
    
    	err := e.marshal(v, encOpts{escapeHTML: true})
    	if err != nil {
    		return nil, err
    	}
    	buf := append([]byte(nil), e.Bytes()...)
    
    	return buf, nil
    }
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 00:18:55 UTC 2024
    - 36.2K bytes
    - Viewed (0)
Back to top