goavro icon indicating copy to clipboard operation
goavro copied to clipboard

Empty arrays are not encoded into native correctly

Open dbirkman-paloalto opened this issue 4 years ago • 0 comments

nativeOutput is not identical to nativeInput:

	codec, err := goavro.NewCodec(`
        {
          "type": "record",
          "name": "name",
          "fields" : [
            {"name": "a", "type": [{
                                    "items": "string",
                                    "type": "array"
                                }]}
          ]
        }`)
	if err != nil {
		fmt.Println(err)
	}

	nativeInput := map[string]interface{}{
		"a": map[string]interface{}{"array": []interface{}{}},
	}

	textual, err := codec.TextualFromNative(nil, nativeInput)
	if err != nil {
		fmt.Println(err)
	}

	nativeOutput, _, err := codec.NativeFromTextual(textual)
	if err != nil {
		fmt.Println(err)
	}

	fmt.Println(reflect.DeepEqual(nativeInput, nativeOutput))    // RETURNS false!!!

dbirkman-paloalto avatar Nov 15 '20 20:11 dbirkman-paloalto