From 1a2c7daec4a73dc46b8718326046c56491dd09e2 Mon Sep 17 00:00:00 2001 From: Vasiliy Faronov Date: Sun, 26 May 2019 04:51:33 +0300 Subject: [PATCH] Fix misleading text about duplicate keys in JSON (#141) Per RFC 8259 Section 4, behavior on duplicate keys is unspecified. Fixes #140. --- README.md | 4 ++-- log.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5429b13..e5008b9 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/log.go b/log.go index 846b9ca..21eb8e4 100644 --- a/log.go +++ b/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 (