See tests for more usage examples.
The decoder accepts an io.Reader
and can decode xml to a *Message
or json
.
Decode NewRx (xml) file:
file, err := os.Open("testdata/sample-newrx.xml")
if err != nil {
log.Fatal(err)
}
defer file.Close()
script := ncpdp.NewDecoder(file)
message, err := script.Decode()
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", message.Body.NewRx)
Get JSON representation:
message, err := script.ToJson()
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", string(message))