Skip to content

Latest commit

 

History

History
36 lines (27 loc) · 715 Bytes

README.md

File metadata and controls

36 lines (27 loc) · 715 Bytes

codecov

NCPDP Script 2017071

Usage

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))