Skip to content

Commit

Permalink
fix: do not produce null fields in marshalled json
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Aug 25, 2023
1 parent bdd7f87 commit a24e870
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions routing/http/types/record_peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,18 @@ func (pr PeerRecord) MarshalJSON() ([]byte, error) {
m[key] = val
}
}

// Schema and ID must always be set.
m["Schema"] = pr.Schema
m["ID"] = pr.ID
m["Addrs"] = pr.Addrs
m["Protocols"] = pr.Protocols

if pr.Addrs != nil {
m["Addrs"] = pr.Addrs
}

if pr.Protocols != nil {
m["Protocols"] = pr.Protocols
}

return drjson.MarshalJSONBytes(m)
}

0 comments on commit a24e870

Please sign in to comment.