From f1a6a94afd32ed3364eef57ce8dcd460987c2765 Mon Sep 17 00:00:00 2001 From: Bailey Wickham Date: Wed, 28 Nov 2018 18:04:20 -0800 Subject: [PATCH 1/2] Added warning for capital field names in structs Names without capital letters will be ignored by the JSON Marshaller. This may cause confusion when fields are not being unmarshalled correctly without a warning why. --- examples/json/json.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/json/json.go b/examples/json/json.go index 6a1f56d..101a1cb 100644 --- a/examples/json/json.go +++ b/examples/json/json.go @@ -14,6 +14,8 @@ type response1 struct { Page int Fruits []string } +// Fields must have capital letters to be exposed to other +// programs such as the JSON Marshaller. type response2 struct { Page int `json:"page"` Fruits []string `json:"fruits"` From 99218c520a60dca287cb0d01c91d7e8772296225 Mon Sep 17 00:00:00 2001 From: Bailey Wickham Date: Sun, 1 Sep 2019 16:07:33 -0700 Subject: [PATCH 2/2] Update export explanation --- examples/json/json.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/json/json.go b/examples/json/json.go index 101a1cb..bd91a8b 100644 --- a/examples/json/json.go +++ b/examples/json/json.go @@ -14,8 +14,8 @@ type response1 struct { Page int Fruits []string } -// Fields must have capital letters to be exposed to other -// programs such as the JSON Marshaller. +// Only exported fields will be encoded/decoded in JSON. +// Fields must start with capital letters to be exported. type response2 struct { Page int `json:"page"` Fruits []string `json:"fruits"`