• Leigh McCulloch's avatar
    encoding/xml, encoding/json: docs and examples using custom marshalers · d70b0ece
    Leigh McCulloch authored
    Both the encoding/xml and encoding/json packages support custom
    marshalers for JSON and XML, as well as the basic encoding.TextMarshaler
    and encoding.TextUnmarshaler interfaces, but the docs and examples for
    these are missing.
    
    There are docs for how to use encoding.TextMarshaler and
    encoding.TextUnmarshaler in encoding/json, but not encoding/xml. There
    are no examples for how to use them with either json or xml. This commit
    includes docs for encoding/xml and examples for both encoding/json and
    encoding/xml.
    
    There is an example using custom marshalers MarshalJSON and
    UnmarshalJSON in encoding/json, but not MarshalXML and UnmarshalXML in
    encoding/json. These docs are more so necessary for encoding/xml because
    the complexities of XML documents is significantly greater than JSON
    documents which more often leads to the need for custom marshaling. The
    encoding/json package includes an example of how to write a custom
    marshaler, and this commit includes the same example for the xml
    package.
    
    All examples are mirrored off the existing custom marshaler example in
    encoding/json.
    
    Fixes #6859
    
    Change-Id: Ic93abc27c0b4d5e48dea6ede4e20b1bedca4ab39
    Reviewed-on: https://go-review.googlesource.com/c/76350
    Run-TryBot: Ian Lance Taylor <iant@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    d70b0ece
Name
Last commit
Last update
..
ascii85 Loading commit data...
asn1 Loading commit data...
base32 Loading commit data...
base64 Loading commit data...
binary Loading commit data...
csv Loading commit data...
gob Loading commit data...
hex Loading commit data...
json Loading commit data...
pem Loading commit data...
xml Loading commit data...
encoding.go Loading commit data...