protobuf for net

This commit is contained in:
Darien Raymond committed 2016-08-27 00:04:35 +02:00
1 parent 64e38ba851
commit cdb4c56546
20 files changed
+323 -77

No files matched your search

+13 -6
View File
@@ -6,15 +6,22 @@ import (
"encoding/json"
)
type AddressJson struct {
Address Address
}
func (this *AddressJson) UnmarshalJSON(data []byte) error {
func (this *AddressPB) UnmarshalJSON(data []byte) error {
var rawStr string
if err := json.Unmarshal(data, &rawStr); err != nil {
return err
}
this.Address = ParseAddress(rawStr)
addr := ParseAddress(rawStr)
switch addr.Family() {
case AddressFamilyIPv4, AddressFamilyIPv6:
this.Address = &AddressPB_Ip{
Ip: []byte(addr.IP()),
}
case AddressFamilyDomain:
this.Address = &AddressPB_Domain{
Domain: addr.Domain(),
}
}
return nil
}