Skip to content

Commit

Permalink
Add extreme map example.
Browse files Browse the repository at this point in the history
  • Loading branch information
clbanning committed Aug 28, 2020
1 parent f52ce10 commit 2b32986
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions anyxml.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
<element>3.14159265</element>
<element>true</element>
</mydoc>
An example of encoding a map[interface{}]interface{} value with mixed key types is
in anyxml/examples/goofy_map.go.
*/
package anyxml

Expand Down
23 changes: 23 additions & 0 deletions examples/goofy_map.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import (
"fmt"

any "github.com/clbanning/anyxml"
)

func main() {
data := map[interface{}]interface{}{
"hello": "out there",
1: "number one",
3.12: "pi",
"five": 5,
}

m, err := any.XmlIndent(data,"", " ")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(m))
}
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ output:
&lt;element&gt;true&lt;/element&gt;
&lt;/mydoc&gt;
</code></pre>

An example of encoding a map with mixed key types is in anyxml/examples/goofy_map.go.

0 comments on commit 2b32986

Please sign in to comment.