Fix misleading text about duplicate keys in JSON (#141)
Per RFC 8259 Section 4, behavior on duplicate keys is unspecified. Fixes #140.
This commit is contained in:
parent
ffd0e9625d
commit
1a2c7daec4
|
@ -577,7 +577,7 @@ Log a static string, without any context or `printf`-style templating:
|
|||
|
||||
## Caveats
|
||||
|
||||
Note that zerolog does de-duplication fields. Using the same key multiple times creates multiple keys in final JSON:
|
||||
Note that zerolog does no de-duplication of fields. Using the same key multiple times creates multiple keys in final JSON:
|
||||
|
||||
```go
|
||||
logger := zerolog.New(os.Stderr).With().Timestamp().Logger()
|
||||
|
@ -587,4 +587,4 @@ logger.Info().
|
|||
// Output: {"level":"info","time":1494567715,"time":1494567715,"message":"dup"}
|
||||
```
|
||||
|
||||
However, it’s not a big deal as JSON accepts dup keys; the last one prevails.
|
||||
In this case, many consumers will take the last value, but this is not guaranteed; check yours if in doubt.
|
||||
|
|
4
log.go
4
log.go
|
@ -94,8 +94,8 @@
|
|||
// Msg("dup")
|
||||
// // Output: {"level":"info","time":1494567715,"time":1494567715,"message":"dup"}
|
||||
//
|
||||
// However, it’s not a big deal though as JSON accepts dup keys,
|
||||
// the last one prevails.
|
||||
// In this case, many consumers will take the last value,
|
||||
// but this is not guaranteed; check yours if in doubt.
|
||||
package zerolog
|
||||
|
||||
import (
|
||||
|
|
Loading…
Reference in New Issue