SGJSONTranscoder.Encode supports writing JSON as either raw bytes or an unmarshalled interface
(value interface{})
| 508 | |
| 509 | // SGJSONTranscoder.Encode supports writing JSON as either raw bytes or an unmarshalled interface |
| 510 | func (t *SGJSONTranscoder) Encode(value interface{}) ([]byte, uint32, error) { |
| 511 | switch value.(type) { |
| 512 | case []byte, *[]byte: |
| 513 | return gocb.NewRawJSONTranscoder().Encode(value) |
| 514 | default: |
| 515 | return gocb.NewJSONTranscoder().Encode(value) |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | // SGBinaryTranscoder uses the appropriate raw transcoder for the data type. Provides backward compatibility |
| 520 | // for pre-3.0 documents intended to be binary but written with JSON datatype, and vice versa |