Skip to content

Commit

Permalink
Fix misleading text about duplicate keys in JSON (#141)
Browse files Browse the repository at this point in the history
Per RFC 8259 Section 4, behavior on duplicate keys is unspecified.

Fixes #140.
  • Loading branch information
vfaronov authored and rs committed May 26, 2019
1 parent ffd0e96 commit 1a2c7da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 changes: 2 additions & 2 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit 1a2c7da

Please sign in to comment.