togo/json.go
jolheiser e8a896fbac
Initial commit
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2021-04-08 23:58:22 -05:00

17 lines
325 B
Go

package togo
import (
"encoding/json"
"fmt"
)
func FromJSON(name string, data []byte) (GoStruct, error) {
var m map[string]interface{}
if err := json.Unmarshal(data, &m); err != nil {
return GoStruct{}, fmt.Errorf("could not unmarshal JSON: %v", err)
}
gs := ToGo(name, m)
gs.format = jsonFormat
return gs, nil
}