+16
-5
@@ -4,12 +4,13 @@
|
||||
|
||||
package binaryheap
|
||||
|
||||
import "github.com/emirpasic/gods/containers"
|
||||
import (
|
||||
"github.com/emirpasic/gods/containers"
|
||||
)
|
||||
|
||||
func assertSerializationImplementation() {
|
||||
var _ containers.JSONSerializer = (*Heap)(nil)
|
||||
var _ containers.JSONDeserializer = (*Heap)(nil)
|
||||
}
|
||||
// Assert Serialization implementation
|
||||
var _ containers.JSONSerializer = (*Heap)(nil)
|
||||
var _ containers.JSONDeserializer = (*Heap)(nil)
|
||||
|
||||
// ToJSON outputs the JSON representation of the heap.
|
||||
func (heap *Heap) ToJSON() ([]byte, error) {
|
||||
@@ -20,3 +21,13 @@ func (heap *Heap) ToJSON() ([]byte, error) {
|
||||
func (heap *Heap) FromJSON(data []byte) error {
|
||||
return heap.list.FromJSON(data)
|
||||
}
|
||||
|
||||
// UnmarshalJSON @implements json.Unmarshaler
|
||||
func (heap *Heap) UnmarshalJSON(bytes []byte) error {
|
||||
return heap.FromJSON(bytes)
|
||||
}
|
||||
|
||||
// MarshalJSON @implements json.Marshaler
|
||||
func (heap *Heap) MarshalJSON() ([]byte, error) {
|
||||
return heap.ToJSON()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user