3 files changed,
+7,
-0
+1,
-0
1@@ -1,3 +1,4 @@
2 [submodule "y-crdt"]
3 path = y-crdt
4 url = https://github.com/BTBurke/y-crdt
5+ branch = fix-empty-json-ptr
+0,
-0
+6,
-0
1@@ -351,6 +351,9 @@ func (o *Output) JSON(receiver interface{}) error {
2 func (o *Output) convertToJSONMap() (map[string]interface{}, error) {
3 entriesPtr := C.youtput_read_json_map(o.ptr)
4 if entriesPtr == nil {
5+ if int(o.ptr.len) == 0 {
6+ return make(map[string]interface{}), nil
7+ }
8 return nil, fmt.Errorf("failed to read json map")
9 }
10
11@@ -374,6 +377,9 @@ func (o *Output) convertToJSONMap() (map[string]interface{}, error) {
12 func (o *Output) convertToJSONArray() ([]interface{}, error) {
13 outputsPtr := C.youtput_read_json_array(o.ptr)
14 if outputsPtr == nil {
15+ if int(o.ptr.len) == 0 {
16+ return []interface{}{}, nil
17+ }
18 return nil, fmt.Errorf("failed to read json array")
19 }
20