Commit 35e58e3b authored by Boris Mühmer's avatar Boris Mühmer
Browse files

aded JSON marshalling of points

parent 1a7c8044
Loading
Loading
Loading
Loading
+12 −13
Original line number Diff line number Diff line
@@ -229,19 +229,18 @@ func ParsePoint(s string) Point {
	}
}

//func (p Point) MarshalJSON() ([]byte, error) {
//	s := p.String()
//	return json.Marshal(s)
//}
//
//func (p *Point) UnmarshalJSON(b []byte) error {
//	var s string
//	if err := json.Unmarshal(b, &s); err != nil {
//		return err
//	}
//	*p = ParsePoint(s)
//	return nil
//}
func (p Point) MarshalJSON() ([]byte, error) {
	return json.Marshal(p.String())
}

func (p *Point) UnmarshalJSON(b []byte) error {
	var s string
	if err := json.Unmarshal(b, &s); err != nil {
		return err
	}
	*p = ParsePoint(s)
	return nil
}

func Points() []Point {
	return []Point{