github.com/mymmsc/gox@v1.3.33/util/linkedliststack/serialization.go (about) 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 linkedliststack 6 7 import "github.com/mymmsc/gox/util" 8 9 func assertSerializationImplementation() { 10 var _ util.JSONSerializer = (*Stack)(nil) 11 var _ util.JSONDeserializer = (*Stack)(nil) 12 } 13 14 // ToJSON outputs the JSON representation of the stack. 15 func (stack *Stack) ToJSON() ([]byte, error) { 16 return stack.list.ToJSON() 17 } 18 19 // FromJSON populates the stack from the input JSON representation. 20 func (stack *Stack) FromJSON(data []byte) error { 21 return stack.list.FromJSON(data) 22 }