Example #1
0
File: jv.go Project: ashb/jqrepl
// JvFromJSONBytes takes a utf-8 byte sequence containing JSON and returns the
// jv representation of it.
func JvFromJSONBytes(b []byte) (*Jv, error) {
	jv := C.jv_parse((*C.char)(unsafe.Pointer(&b[0])))

	if C.jv_is_valid(jv) == 0 {
		return nil, _ConvertError(jv)
	}
	return &Jv{jv}, nil
}
Example #2
0
File: jv.go Project: ashb/jqrepl
// JvFromJSONString takes a JSON string and returns the jv representation of
// it.
func JvFromJSONString(str string) (*Jv, error) {
	cs := C.CString(str)
	defer C.free(unsafe.Pointer(cs))
	jv := C.jv_parse(cs)

	if C.jv_is_valid(jv) == 0 {
		return nil, _ConvertError(jv)
	}
	return &Jv{jv}, nil
}
Example #3
0
File: jq.go Project: wxf4150/go-jq
func parseJson(value string) C.jv {
	return C.jv_parse(C.CString(value))
}