github.com/ystia/yorc/v4@v4.3.0/storage/encoding/json.go (about) 1 // Copyright 2019 Bull S.A.S. Atos Technologies - Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois, France. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package encoding 16 17 import "encoding/json" 18 19 // JSONcodec encodes/decodes Go values to/from JSON. 20 // You can use encoding.JSON instead of creating an instance of this struct. 21 type JSONcodec struct{} 22 23 // Marshal encodes a Go value to JSON. 24 func (c JSONcodec) Marshal(v interface{}) ([]byte, error) { 25 return json.Marshal(v) 26 } 27 28 // Unmarshal decodes a JSON value into a Go value. 29 func (c JSONcodec) Unmarshal(data []byte, v interface{}) error { 30 return json.Unmarshal(data, v) 31 }