예제 #1
0
파일: ujson.go 프로젝트: jehiah/go-ujson
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
}
예제 #2
0
파일: ujson.go 프로젝트: jehiah/go-ujson
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
}