Enhance Package JSON representation with Key, ShortKey and FilesHash. #168

This commit is contained in:
Andrey Smirnov
2015-02-05 01:47:10 +03:00
parent d20300b152
commit fa2eef564c
+6 -1
View File
@@ -213,7 +213,12 @@ func (p *Package) String() string {
// MarshalJSON implements json.Marshaller interface
func (p *Package) MarshalJSON() ([]byte, error) {
return json.Marshal(p.Stanza())
stanza := p.Stanza()
stanza["FilesHash"] = fmt.Sprintf("%08x", p.FilesHash)
stanza["Key"] = string(p.Key(""))
stanza["ShortKey"] = string(p.ShortKey(""))
return json.Marshal(stanza)
}
// GetField returns fields from package