Debian Codegraph @

maps/treemap/serialization.go

raw symbols SCIP
1 // Copyright (c) 2015, Emir Pasic. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package treemap
6
7 import (
8 "github.com/emirpasic/gods/v2/containers"
9 )
10
11 // Assert Serialization implementation
12 var _ containers.JSONSerializer = (*Map[string, int])(nil)
13 var _ containers.JSONDeserializer = (*Map[string, int])(nil)
14
15 // ToJSON outputs the JSON representation of the map.
16 func (m *Map[K, V]) ToJSON() ([]byte, error) {
17 return m.tree.ToJSON()
18 }
19
20 // FromJSON populates the map from the input JSON representation.
21 func (m *Map[K, V]) FromJSON(data []byte) error {
22 return m.tree.FromJSON(data)
23 }
24
25 // UnmarshalJSON @implements json.Unmarshaler
26 func (m *Map[K, V]) UnmarshalJSON(bytes []byte) error {
27 return m.FromJSON(bytes)
28 }
29
30 // MarshalJSON @implements json.Marshaler
31 func (m *Map[K, V]) MarshalJSON() ([]byte, error) {
32 return m.ToJSON()
33 }