Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

Commit

Permalink
Add json unmarshaller for Href compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
minhaj10p authored and Asadullah Bin Yousuf committed Dec 11, 2018
1 parent c9f25db commit 593897a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions types/oscal/catalog/href.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ func (h *Href) UnmarshalXMLAttr(attr xml.Attr) error {
return nil
}

func (h *Href) UnmarshalJSON(b []byte) error {
s := string(b)
s = s[1 : len(s)-1]
url, err := url.Parse(s)
if err != nil {
return err
}
h.URL = url
return nil
}

func (h *Href) MarshalJSON() ([]byte, error) {
return json.Marshal(h.String())
}
Expand Down

0 comments on commit 593897a

Please sign in to comment.