Marshal is documented at https://golang.org/pkg/encoding/json/#Marshal
(x any)
| 270 | |
| 271 | // Marshal is documented at https://golang.org/pkg/encoding/json/#Marshal |
| 272 | func Marshal(x any) ([]byte, error) { |
| 273 | var err error |
| 274 | buf := encoderBufferPool.Get().(*encoderBuffer) |
| 275 | |
| 276 | if buf.data, err = Append(buf.data[:0], x, EscapeHTML|SortMapKeys); err != nil { |
| 277 | return nil, err |
| 278 | } |
| 279 | |
| 280 | b := make([]byte, len(buf.data)) |
| 281 | copy(b, buf.data) |
| 282 | encoderBufferPool.Put(buf) |
| 283 | return b, nil |
| 284 | } |
| 285 | |
| 286 | // MarshalIndent is documented at https://golang.org/pkg/encoding/json/#MarshalIndent |
| 287 | func MarshalIndent(x any, prefix, indent string) ([]byte, error) { |
searching dependent graphs…