mirror of
https://github.com/emirpasic/gods
synced 2024-11-16 12:12:59 +00:00
Implements json.Marshaler and json.Unmarshaler
This commit is contained in:
parent
79df803e55
commit
c9a2dcad62
@ -12,6 +12,8 @@ import (
|
|||||||
func assertSerializationImplementation() {
|
func assertSerializationImplementation() {
|
||||||
var _ containers.JSONSerializer = (*List)(nil)
|
var _ containers.JSONSerializer = (*List)(nil)
|
||||||
var _ containers.JSONDeserializer = (*List)(nil)
|
var _ containers.JSONDeserializer = (*List)(nil)
|
||||||
|
var _ json.Marshaler = (*List)(nil)
|
||||||
|
var _ json.Unmarshaler = (*List)(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToJSON outputs the JSON representation of list's elements.
|
// ToJSON outputs the JSON representation of list's elements.
|
||||||
@ -27,3 +29,13 @@ func (list *List) FromJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @implements json.Unmarshaler
|
||||||
|
func (list *List) UnmarshalJSON(bytes []byte) error {
|
||||||
|
return list.FromJSON(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @implements json.Marshaler
|
||||||
|
func (list *List) MarshalJSON() ([]byte, error) {
|
||||||
|
return list.ToJSON()
|
||||||
|
}
|
||||||
|
@ -12,6 +12,8 @@ import (
|
|||||||
func assertSerializationImplementation() {
|
func assertSerializationImplementation() {
|
||||||
var _ containers.JSONSerializer = (*List)(nil)
|
var _ containers.JSONSerializer = (*List)(nil)
|
||||||
var _ containers.JSONDeserializer = (*List)(nil)
|
var _ containers.JSONDeserializer = (*List)(nil)
|
||||||
|
var _ json.Marshaler = (*List)(nil)
|
||||||
|
var _ json.Unmarshaler = (*List)(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToJSON outputs the JSON representation of list's elements.
|
// ToJSON outputs the JSON representation of list's elements.
|
||||||
@ -29,3 +31,13 @@ func (list *List) FromJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @implements json.Unmarshaler
|
||||||
|
func (list *List) UnmarshalJSON(bytes []byte) error {
|
||||||
|
return list.FromJSON(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @implements json.Marshaler
|
||||||
|
func (list *List) MarshalJSON() ([]byte, error) {
|
||||||
|
return list.ToJSON()
|
||||||
|
}
|
||||||
|
@ -12,6 +12,8 @@ import (
|
|||||||
func assertSerializationImplementation() {
|
func assertSerializationImplementation() {
|
||||||
var _ containers.JSONSerializer = (*List)(nil)
|
var _ containers.JSONSerializer = (*List)(nil)
|
||||||
var _ containers.JSONDeserializer = (*List)(nil)
|
var _ containers.JSONDeserializer = (*List)(nil)
|
||||||
|
var _ json.Marshaler = (*List)(nil)
|
||||||
|
var _ json.Unmarshaler = (*List)(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToJSON outputs the JSON representation of list's elements.
|
// ToJSON outputs the JSON representation of list's elements.
|
||||||
@ -29,3 +31,13 @@ func (list *List) FromJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @implements json.Unmarshaler
|
||||||
|
func (list *List) UnmarshalJSON(bytes []byte) error {
|
||||||
|
return list.FromJSON(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @implements json.Marshaler
|
||||||
|
func (list *List) MarshalJSON() ([]byte, error) {
|
||||||
|
return list.ToJSON()
|
||||||
|
}
|
||||||
|
@ -12,6 +12,8 @@ import (
|
|||||||
func assertSerializationImplementation() {
|
func assertSerializationImplementation() {
|
||||||
var _ containers.JSONSerializer = (*Map)(nil)
|
var _ containers.JSONSerializer = (*Map)(nil)
|
||||||
var _ containers.JSONDeserializer = (*Map)(nil)
|
var _ containers.JSONDeserializer = (*Map)(nil)
|
||||||
|
var _ json.Marshaler = (*Map)(nil)
|
||||||
|
var _ json.Unmarshaler = (*Map)(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToJSON outputs the JSON representation of the map.
|
// ToJSON outputs the JSON representation of the map.
|
||||||
@ -31,3 +33,13 @@ func (m *Map) FromJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @implements json.Unmarshaler
|
||||||
|
func (m *Map) UnmarshalJSON(bytes []byte) error {
|
||||||
|
return m.FromJSON(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @implements json.Marshaler
|
||||||
|
func (m *Map) MarshalJSON() ([]byte, error) {
|
||||||
|
return m.ToJSON()
|
||||||
|
}
|
||||||
|
@ -13,6 +13,8 @@ import (
|
|||||||
func assertSerializationImplementation() {
|
func assertSerializationImplementation() {
|
||||||
var _ containers.JSONSerializer = (*Map)(nil)
|
var _ containers.JSONSerializer = (*Map)(nil)
|
||||||
var _ containers.JSONDeserializer = (*Map)(nil)
|
var _ containers.JSONDeserializer = (*Map)(nil)
|
||||||
|
var _ json.Marshaler = (*Map)(nil)
|
||||||
|
var _ json.Unmarshaler = (*Map)(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToJSON outputs the JSON representation of the map.
|
// ToJSON outputs the JSON representation of the map.
|
||||||
@ -36,3 +38,13 @@ func (m *Map) FromJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @implements json.Unmarshaler
|
||||||
|
func (m *Map) UnmarshalJSON(bytes []byte) error {
|
||||||
|
return m.FromJSON(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @implements json.Marshaler
|
||||||
|
func (m *Map) MarshalJSON() ([]byte, error) {
|
||||||
|
return m.ToJSON()
|
||||||
|
}
|
||||||
|
@ -14,6 +14,8 @@ import (
|
|||||||
func assertSerializationImplementation() {
|
func assertSerializationImplementation() {
|
||||||
var _ containers.JSONSerializer = (*Map)(nil)
|
var _ containers.JSONSerializer = (*Map)(nil)
|
||||||
var _ containers.JSONDeserializer = (*Map)(nil)
|
var _ containers.JSONDeserializer = (*Map)(nil)
|
||||||
|
var _ json.Marshaler = (*Map)(nil)
|
||||||
|
var _ json.Unmarshaler = (*Map)(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToJSON outputs the JSON representation of map.
|
// ToJSON outputs the JSON representation of map.
|
||||||
@ -101,3 +103,13 @@ func (m *Map) FromJSON(data []byte) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @implements json.Unmarshaler
|
||||||
|
func (m *Map) UnmarshalJSON(bytes []byte) error {
|
||||||
|
return m.FromJSON(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @implements json.Marshaler
|
||||||
|
func (m *Map) MarshalJSON() ([]byte, error) {
|
||||||
|
return m.ToJSON()
|
||||||
|
}
|
||||||
|
@ -13,6 +13,8 @@ import (
|
|||||||
func assertSerializationImplementation() {
|
func assertSerializationImplementation() {
|
||||||
var _ containers.JSONSerializer = (*Map)(nil)
|
var _ containers.JSONSerializer = (*Map)(nil)
|
||||||
var _ containers.JSONDeserializer = (*Map)(nil)
|
var _ containers.JSONDeserializer = (*Map)(nil)
|
||||||
|
var _ json.Marshaler = (*Map)(nil)
|
||||||
|
var _ json.Unmarshaler = (*Map)(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToJSON outputs the JSON representation of the map.
|
// ToJSON outputs the JSON representation of the map.
|
||||||
@ -37,3 +39,13 @@ func (m *Map) FromJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @implements json.Unmarshaler
|
||||||
|
func (m *Map) UnmarshalJSON(bytes []byte) error {
|
||||||
|
return m.FromJSON(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @implements json.Marshaler
|
||||||
|
func (m *Map) MarshalJSON() ([]byte, error) {
|
||||||
|
return m.ToJSON()
|
||||||
|
}
|
||||||
|
@ -4,11 +4,17 @@
|
|||||||
|
|
||||||
package treemap
|
package treemap
|
||||||
|
|
||||||
import "github.com/emirpasic/gods/containers"
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/emirpasic/gods/containers"
|
||||||
|
)
|
||||||
|
|
||||||
func assertSerializationImplementation() {
|
func assertSerializationImplementation() {
|
||||||
var _ containers.JSONSerializer = (*Map)(nil)
|
var _ containers.JSONSerializer = (*Map)(nil)
|
||||||
var _ containers.JSONDeserializer = (*Map)(nil)
|
var _ containers.JSONDeserializer = (*Map)(nil)
|
||||||
|
var _ json.Marshaler = (*Map)(nil)
|
||||||
|
var _ json.Unmarshaler = (*Map)(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToJSON outputs the JSON representation of the map.
|
// ToJSON outputs the JSON representation of the map.
|
||||||
@ -20,3 +26,13 @@ func (m *Map) ToJSON() ([]byte, error) {
|
|||||||
func (m *Map) FromJSON(data []byte) error {
|
func (m *Map) FromJSON(data []byte) error {
|
||||||
return m.tree.FromJSON(data)
|
return m.tree.FromJSON(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @implements json.Unmarshaler
|
||||||
|
func (m *Map) UnmarshalJSON(bytes []byte) error {
|
||||||
|
return m.FromJSON(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @implements json.Marshaler
|
||||||
|
func (m *Map) MarshalJSON() ([]byte, error) {
|
||||||
|
return m.ToJSON()
|
||||||
|
}
|
||||||
|
@ -12,6 +12,8 @@ import (
|
|||||||
func assertSerializationImplementation() {
|
func assertSerializationImplementation() {
|
||||||
var _ containers.JSONSerializer = (*Set)(nil)
|
var _ containers.JSONSerializer = (*Set)(nil)
|
||||||
var _ containers.JSONDeserializer = (*Set)(nil)
|
var _ containers.JSONDeserializer = (*Set)(nil)
|
||||||
|
var _ json.Marshaler = (*Set)(nil)
|
||||||
|
var _ json.Unmarshaler = (*Set)(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToJSON outputs the JSON representation of the set.
|
// ToJSON outputs the JSON representation of the set.
|
||||||
@ -29,3 +31,13 @@ func (set *Set) FromJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @implements json.Unmarshaler
|
||||||
|
func (set *Set) UnmarshalJSON(bytes []byte) error {
|
||||||
|
return set.FromJSON(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @implements json.Marshaler
|
||||||
|
func (set *Set) MarshalJSON() ([]byte, error) {
|
||||||
|
return set.ToJSON()
|
||||||
|
}
|
||||||
|
@ -12,6 +12,8 @@ import (
|
|||||||
func assertSerializationImplementation() {
|
func assertSerializationImplementation() {
|
||||||
var _ containers.JSONSerializer = (*Set)(nil)
|
var _ containers.JSONSerializer = (*Set)(nil)
|
||||||
var _ containers.JSONDeserializer = (*Set)(nil)
|
var _ containers.JSONDeserializer = (*Set)(nil)
|
||||||
|
var _ json.Marshaler = (*Set)(nil)
|
||||||
|
var _ json.Unmarshaler = (*Set)(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToJSON outputs the JSON representation of the set.
|
// ToJSON outputs the JSON representation of the set.
|
||||||
@ -29,3 +31,13 @@ func (set *Set) FromJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @implements json.Unmarshaler
|
||||||
|
func (set *Set) UnmarshalJSON(bytes []byte) error {
|
||||||
|
return set.FromJSON(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @implements json.Marshaler
|
||||||
|
func (set *Set) MarshalJSON() ([]byte, error) {
|
||||||
|
return set.ToJSON()
|
||||||
|
}
|
||||||
|
@ -12,6 +12,8 @@ import (
|
|||||||
func assertSerializationImplementation() {
|
func assertSerializationImplementation() {
|
||||||
var _ containers.JSONSerializer = (*Set)(nil)
|
var _ containers.JSONSerializer = (*Set)(nil)
|
||||||
var _ containers.JSONDeserializer = (*Set)(nil)
|
var _ containers.JSONDeserializer = (*Set)(nil)
|
||||||
|
var _ json.Marshaler = (*Set)(nil)
|
||||||
|
var _ json.Unmarshaler = (*Set)(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToJSON outputs the JSON representation of the set.
|
// ToJSON outputs the JSON representation of the set.
|
||||||
@ -29,3 +31,13 @@ func (set *Set) FromJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @implements json.Unmarshaler
|
||||||
|
func (set *Set) UnmarshalJSON(bytes []byte) error {
|
||||||
|
return set.FromJSON(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @implements json.Marshaler
|
||||||
|
func (set *Set) MarshalJSON() ([]byte, error) {
|
||||||
|
return set.ToJSON()
|
||||||
|
}
|
||||||
|
@ -4,11 +4,17 @@
|
|||||||
|
|
||||||
package arraystack
|
package arraystack
|
||||||
|
|
||||||
import "github.com/emirpasic/gods/containers"
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/emirpasic/gods/containers"
|
||||||
|
)
|
||||||
|
|
||||||
func assertSerializationImplementation() {
|
func assertSerializationImplementation() {
|
||||||
var _ containers.JSONSerializer = (*Stack)(nil)
|
var _ containers.JSONSerializer = (*Stack)(nil)
|
||||||
var _ containers.JSONDeserializer = (*Stack)(nil)
|
var _ containers.JSONDeserializer = (*Stack)(nil)
|
||||||
|
var _ json.Marshaler = (*Stack)(nil)
|
||||||
|
var _ json.Unmarshaler = (*Stack)(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToJSON outputs the JSON representation of the stack.
|
// ToJSON outputs the JSON representation of the stack.
|
||||||
@ -20,3 +26,13 @@ func (stack *Stack) ToJSON() ([]byte, error) {
|
|||||||
func (stack *Stack) FromJSON(data []byte) error {
|
func (stack *Stack) FromJSON(data []byte) error {
|
||||||
return stack.list.FromJSON(data)
|
return stack.list.FromJSON(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @implements json.Unmarshaler
|
||||||
|
func (stack *Stack) UnmarshalJSON(bytes []byte) error {
|
||||||
|
return stack.FromJSON(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @implements json.Marshaler
|
||||||
|
func (stack *Stack) MarshalJSON() ([]byte, error) {
|
||||||
|
return stack.ToJSON()
|
||||||
|
}
|
||||||
|
@ -4,11 +4,17 @@
|
|||||||
|
|
||||||
package linkedliststack
|
package linkedliststack
|
||||||
|
|
||||||
import "github.com/emirpasic/gods/containers"
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/emirpasic/gods/containers"
|
||||||
|
)
|
||||||
|
|
||||||
func assertSerializationImplementation() {
|
func assertSerializationImplementation() {
|
||||||
var _ containers.JSONSerializer = (*Stack)(nil)
|
var _ containers.JSONSerializer = (*Stack)(nil)
|
||||||
var _ containers.JSONDeserializer = (*Stack)(nil)
|
var _ containers.JSONDeserializer = (*Stack)(nil)
|
||||||
|
var _ json.Marshaler = (*Stack)(nil)
|
||||||
|
var _ json.Unmarshaler = (*Stack)(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToJSON outputs the JSON representation of the stack.
|
// ToJSON outputs the JSON representation of the stack.
|
||||||
@ -20,3 +26,13 @@ func (stack *Stack) ToJSON() ([]byte, error) {
|
|||||||
func (stack *Stack) FromJSON(data []byte) error {
|
func (stack *Stack) FromJSON(data []byte) error {
|
||||||
return stack.list.FromJSON(data)
|
return stack.list.FromJSON(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @implements json.Unmarshaler
|
||||||
|
func (stack *Stack) UnmarshalJSON(bytes []byte) error {
|
||||||
|
return stack.FromJSON(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @implements json.Marshaler
|
||||||
|
func (stack *Stack) MarshalJSON() ([]byte, error) {
|
||||||
|
return stack.ToJSON()
|
||||||
|
}
|
||||||
|
@ -13,6 +13,8 @@ import (
|
|||||||
func assertSerializationImplementation() {
|
func assertSerializationImplementation() {
|
||||||
var _ containers.JSONSerializer = (*Tree)(nil)
|
var _ containers.JSONSerializer = (*Tree)(nil)
|
||||||
var _ containers.JSONDeserializer = (*Tree)(nil)
|
var _ containers.JSONDeserializer = (*Tree)(nil)
|
||||||
|
var _ json.Marshaler = (*Tree)(nil)
|
||||||
|
var _ json.Unmarshaler = (*Tree)(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToJSON outputs the JSON representation of the tree.
|
// ToJSON outputs the JSON representation of the tree.
|
||||||
@ -37,3 +39,13 @@ func (tree *Tree) FromJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @implements json.Unmarshaler
|
||||||
|
func (tree *Tree) UnmarshalJSON(bytes []byte) error {
|
||||||
|
return tree.FromJSON(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @implements json.Marshaler
|
||||||
|
func (tree *Tree) MarshalJSON() ([]byte, error) {
|
||||||
|
return tree.ToJSON()
|
||||||
|
}
|
||||||
|
@ -4,11 +4,17 @@
|
|||||||
|
|
||||||
package binaryheap
|
package binaryheap
|
||||||
|
|
||||||
import "github.com/emirpasic/gods/containers"
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/emirpasic/gods/containers"
|
||||||
|
)
|
||||||
|
|
||||||
func assertSerializationImplementation() {
|
func assertSerializationImplementation() {
|
||||||
var _ containers.JSONSerializer = (*Heap)(nil)
|
var _ containers.JSONSerializer = (*Heap)(nil)
|
||||||
var _ containers.JSONDeserializer = (*Heap)(nil)
|
var _ containers.JSONDeserializer = (*Heap)(nil)
|
||||||
|
var _ json.Marshaler = (*Heap)(nil)
|
||||||
|
var _ json.Unmarshaler = (*Heap)(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToJSON outputs the JSON representation of the heap.
|
// ToJSON outputs the JSON representation of the heap.
|
||||||
@ -20,3 +26,13 @@ func (heap *Heap) ToJSON() ([]byte, error) {
|
|||||||
func (heap *Heap) FromJSON(data []byte) error {
|
func (heap *Heap) FromJSON(data []byte) error {
|
||||||
return heap.list.FromJSON(data)
|
return heap.list.FromJSON(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @implements json.Unmarshaler
|
||||||
|
func (heap *Heap) UnmarshalJSON(bytes []byte) error {
|
||||||
|
return heap.FromJSON(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @implements json.Marshaler
|
||||||
|
func (heap *Heap) MarshalJSON() ([]byte, error) {
|
||||||
|
return heap.ToJSON()
|
||||||
|
}
|
||||||
|
@ -13,6 +13,8 @@ import (
|
|||||||
func assertSerializationImplementation() {
|
func assertSerializationImplementation() {
|
||||||
var _ containers.JSONSerializer = (*Tree)(nil)
|
var _ containers.JSONSerializer = (*Tree)(nil)
|
||||||
var _ containers.JSONDeserializer = (*Tree)(nil)
|
var _ containers.JSONDeserializer = (*Tree)(nil)
|
||||||
|
var _ json.Marshaler = (*Tree)(nil)
|
||||||
|
var _ json.Unmarshaler = (*Tree)(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToJSON outputs the JSON representation of the tree.
|
// ToJSON outputs the JSON representation of the tree.
|
||||||
@ -37,3 +39,13 @@ func (tree *Tree) FromJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @implements json.Unmarshaler
|
||||||
|
func (tree *Tree) UnmarshalJSON(bytes []byte) error {
|
||||||
|
return tree.FromJSON(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @implements json.Marshaler
|
||||||
|
func (tree *Tree) MarshalJSON() ([]byte, error) {
|
||||||
|
return tree.ToJSON()
|
||||||
|
}
|
||||||
|
@ -13,6 +13,8 @@ import (
|
|||||||
func assertSerializationImplementation() {
|
func assertSerializationImplementation() {
|
||||||
var _ containers.JSONSerializer = (*Tree)(nil)
|
var _ containers.JSONSerializer = (*Tree)(nil)
|
||||||
var _ containers.JSONDeserializer = (*Tree)(nil)
|
var _ containers.JSONDeserializer = (*Tree)(nil)
|
||||||
|
var _ json.Marshaler = (*Tree)(nil)
|
||||||
|
var _ json.Unmarshaler = (*Tree)(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToJSON outputs the JSON representation of the tree.
|
// ToJSON outputs the JSON representation of the tree.
|
||||||
@ -37,3 +39,13 @@ func (tree *Tree) FromJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @implements json.Unmarshaler
|
||||||
|
func (tree *Tree) UnmarshalJSON(bytes []byte) error {
|
||||||
|
return tree.FromJSON(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @implements json.Marshaler
|
||||||
|
func (tree *Tree) MarshalJSON() ([]byte, error) {
|
||||||
|
return tree.ToJSON()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user