Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Avro, mail # dev - GenericRecord.toString does not handle enums properly


Copy link to this message
-
GenericRecord.toString does not handle enums properly
Jay Kreps 2010-12-15, 21:13
The output from GenericRecord.toString in Java is not valid JSON, for
example a record with the schema:

{
  "type": "record",
  "name": "TestRecord",
  "fields" : [
    {"name":"enum_field",
     "type":{"type":"enum",
                 "symbols":["a", "b"],
                 "name":"MyEnumType"}},
  ]
}

Should be output as
{"enum_field":"a"}
but is output as
{"emum_field":a}

The later is not really JSON. I saw this on 1.4 but I think it exists
on trunk too.

Is this a known issue? I think the fix is just to add another special
case in GenericData.toString()...

-Jay
+
Doug Cutting 2010-12-15, 21:38