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