diff options
| author | Robert Griesemer <gri@golang.org> | 2015-09-28 10:47:39 -0700 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2015-09-28 18:08:18 +0000 |
| commit | cbe8a3531adf2ad4c8353678be08cf401831cd2c (patch) | |
| tree | 07c3a10137695351cddbee1e9ba1c2d5bc9d27e7 /src/encoding/json | |
| parent | 3d4cd144cc1e6fb554b12695d0d190a2db0c6a2c (diff) | |
| download | go-cbe8a3531adf2ad4c8353678be08cf401831cd2c.tar.xz | |
encoding/json: document that encoding.TextMarshaler is used if no (json) Marshaler is present
Change-Id: I63da54832548c325e47dc54aaa5b5112e1f3b3ba
Reviewed-on: https://go-review.googlesource.com/15048
Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/encoding/json')
| -rw-r--r-- | src/encoding/json/encode.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/encoding/json/encode.go b/src/encoding/json/encode.go index 90782deb70..21f403e788 100644 --- a/src/encoding/json/encode.go +++ b/src/encoding/json/encode.go @@ -30,7 +30,10 @@ import ( // Marshal traverses the value v recursively. // If an encountered value implements the Marshaler interface // and is not a nil pointer, Marshal calls its MarshalJSON method -// to produce JSON. The nil pointer exception is not strictly necessary +// to produce JSON. If no MarshalJSON method is present but the +// value implements encoding.TextMarshaler instead, Marshal calls +// its MarshalText method. +// The nil pointer exception is not strictly necessary // but mimics a similar, necessary exception in the behavior of // UnmarshalJSON. // |
