Example #1
0
func Unmarshal(d []byte) (interface{}, error) {
	cData := (*C.char)(unsafe.Pointer(&d[0]))
	ret := C.decodeString(cData, C.size_t(len(d)))
	if ret == nil {
		return nil, &SyntaxError{"failed to decode JSON", 0}
	}
	return *(*interface{})(ret), nil
}
Example #2
0
func UnmarshalUjson(d []byte) (*Ujson, error) {
	cData := (*C.char)(unsafe.Pointer(&d[0]))
	ret := C.decodeString(cData, C.size_t(len(d)))
	if ret == nil {
		return nil, &SyntaxError{"failed to decode JSON", 0}
	}
	return &Ujson{ret}, nil
}