hyperledger/burrow · source.go
go logo
func FromJSONString(jsonString string, conf interface{}) error {
	err := json.Unmarshal(([]byte)(jsonString), conf)
	if err != nil {
		return err
	}
	return nil
}
Similar code snippets
1.
hashicorp/terraform · expand_json.go
Match rating: 69.18% · See similar code snippets
go logo
func ExpandJsonFromString(jsonString string) (map[string]interface{}, error) {
	var result map[string]interface{}

	err := json.Unmarshal([]byte(jsonString), &result)

	return result, err
}
2.
terraform-providers/terraform-provider-azurerm · resource_arm_template_deployment.go
Match rating: 68.09% · See similar code snippets
go logo
func normalizeJson(jsonString interface{}) string {
	if jsonString == nil || jsonString == "" {
		return ""
	}
	var j interface{}

	if err := json.Unmarshal([]byte(jsonString.(string)), &j); err != nil {
		return fmt.Sprintf("Error parsing JSON: %+v", err)
	}
	b, _ := json.Marshal(j)
	return string(b[:])
}
3.
aphistic/gomol · template.go
Match rating: 67.65% · See similar code snippets
go logo
func tplJSON(data interface{}) (string, error) {
	json, err := json.Marshal(data)
	if err != nil {
		return "", err
	}
	return string(json), nil
}
4.
hyperledger/fabric · couchdoc_conv.go
Match rating: 65.55% · See similar code snippets
go logo
func castToJSON(b []byte) (jsonValue, error) {
	var jsonVal map[string]interface{}
	err := json.Unmarshal(b, &jsonVal)
	err = errors.Wrap(err, "error unmarshalling json data")
	return jsonVal, err
}
5.
gin-gonic/gin · errors.go
Match rating: 65.3% · See similar code snippets
go logo
func (a errorMsgs) JSON() interface{} {
	switch len(a) {
	case 0:
		return nil
	case 1:
		return a.Last().JSON()
	default:
		json := make([]interface{}, len(a))
		for i, err := range a {
			json[i] = err.JSON()
		}
		return json
	}
}
6.
flynn/flynn · httphelper.go
Match rating: 64.05% · See similar code snippets
go logo
func (jsonError JSONError) Error() string {
	return fmt.Sprintf("%s: %s", jsonError.Code, jsonError.Message)
}
7.
thecodeteam/goisilon · api.go
Match rating: 63.84% · See similar code snippets
go logo
func parseJSONError(r *http.Response) error {
	jsonError := &JSONError{}
	if err := json.NewDecoder(r.Body).Decode(jsonError); err != nil {
		return err
	}

	jsonError.StatusCode = r.StatusCode
	if jsonError.Err[0].Message == "" {
		jsonError.Err[0].Message = r.Status
	}

	return jsonError
}
8.
hyperledger/fabric · couchdoc_conv.go
Match rating: 63.8% · See similar code snippets
go logo
func tryCastingToJSON(b []byte) (isJSON bool, val jsonValue) {
	var jsonVal map[string]interface{}
	err := json.Unmarshal(b, &jsonVal)
	return err == nil, jsonValue(jsonVal)
}
9.
minio/minio · admin-handlers.go
Match rating: 62.78% · See similar code snippets
go logo
func convertValueType(elem []byte, jsonType gjson.Type) (interface{}, error) {
	str := string(elem)
	switch jsonType {
	case gjson.False, gjson.True:
		return strconv.ParseBool(str)
	case gjson.JSON:
		return gjson.Parse(str).Value(), nil
	case gjson.String:
		return str, nil
	case gjson.Number:
		return strconv.ParseFloat(str, 64)
	default:
		return nil, nil
	}
}
10.
tidwall/gjson · gjson.go
Match rating: 62.34% · See similar code snippets
go logo
func tolit(json string) (raw string) {
	for i := 1; i < len(json); i++ {
		if json[i] < 'a' || json[i] > 'z' {
			return json[:i]
		}
	}
	return json
}