NewJSONEncoder creates a fast, low-allocation JSON encoder. The encoder appropriately escapes all field keys and values. Note that the encoder doesn't deduplicate keys, so it's possible to produce a message like {"foo":"bar","foo":"baz"} This is permitted by the JSON specification, but not encou
(cfg EncoderConfig)
| 75 | // pair) when unmarshaling, but users should attempt to avoid adding duplicate |
| 76 | // keys. |
| 77 | func NewJSONEncoder(cfg EncoderConfig) Encoder { |
| 78 | return newJSONEncoder(cfg, false) |
| 79 | } |
| 80 | |
| 81 | func newJSONEncoder(cfg EncoderConfig, spaced bool) *jsonEncoder { |
| 82 | if cfg.SkipLineEnding { |