Skip to content

Commit

Permalink
feat: update docs to include new json helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
nilslice committed Feb 2, 2024
1 parent 19cac8e commit e00df09
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,19 @@ type Sum struct {
//export add
func add() int32 {
params := Add{}
err := json.Unmarshal(pdk.Input(), &params)
// use json input helper, which automatically unmarshals the plugin input into your struct
err := pdk.InputJSON(&params)
if err != nil {
pdk.SetError(err)
return 1
}
sum := Sum{Sum: params.A + params.B}
output, err := json.Marshal(sum)
// use json output helper, which automatically marshals your struct to the plugin output
output, err := pdk.OutputJSON(sum)
if err != nil {
pdk.SetError(err)
return 1
}
pdk.Output(output)
return 0
}
```
Expand Down

0 comments on commit e00df09

Please sign in to comment.