Skip to content

Commit

Permalink
Add code for one of the diagrams.
Browse files Browse the repository at this point in the history
  • Loading branch information
technosophos committed Feb 28, 2016
1 parent 005d899 commit 6c54811
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions chapter11/annotations/jsonxml/jsonxml.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import (
"encoding/json"
"encoding/xml"
"os"
)

type Person struct {
FirstName string `json:"first" xml:"firstName,attr"`
LastName string `json:"last" xml:"lastName"`
}

func main() {
p := &Person{FirstName: "Inigo", LastName: "Montoya"}
j, _ := json.MarshalIndent(p, "", " ")
os.Stdout.Write(j)
println()

x, _ := xml.MarshalIndent(p, "", " ")
os.Stdout.Write(x)
}

0 comments on commit 6c54811

Please sign in to comment.