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:
Vasiliy Faronov 2019-05-26 04:51:33 +03:00 committed by Olivier Poitrey
parent ffd0e9625d
commit 1a2c7daec4
2 changed files with 4 additions and 4 deletions

View File

@ -577,7 +577,7 @@ Log a static string, without any context or `printf`-style templating:
## Caveats ## 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 ```go
logger := zerolog.New(os.Stderr).With().Timestamp().Logger() logger := zerolog.New(os.Stderr).With().Timestamp().Logger()
@ -587,4 +587,4 @@ logger.Info().
// Output: {"level":"info","time":1494567715,"time":1494567715,"message":"dup"} // Output: {"level":"info","time":1494567715,"time":1494567715,"message":"dup"}
``` ```
However, its 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
View File

@ -94,8 +94,8 @@
// Msg("dup") // Msg("dup")
// // Output: {"level":"info","time":1494567715,"time":1494567715,"message":"dup"} // // Output: {"level":"info","time":1494567715,"time":1494567715,"message":"dup"}
// //
// However, its not a big deal though as JSON accepts dup keys, // In this case, many consumers will take the last value,
// the last one prevails. // but this is not guaranteed; check yours if in doubt.
package zerolog package zerolog
import ( import (