You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Jay Kreps (JIRA)" <ji...@apache.org> on 2010/12/15 22:56:02 UTC

[jira] Created: (AVRO-713) GenericRecord.toString can produce invalid JSON

GenericRecord.toString can produce invalid JSON
-----------------------------------------------

                 Key: AVRO-713
                 URL: https://issues.apache.org/jira/browse/AVRO-713
             Project: Avro
          Issue Type: Bug
          Components: java
    Affects Versions: 1.4.1
            Reporter: Jay Kreps


The GenericData.toString method can produce invalid JSON. The problem is that enums are printed without quotes, as in
{"emum_field":a}
instead of 
{"enum_field":"a"}




-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (AVRO-713) GenericRecord.toString can produce invalid JSON

Posted by "Jay Kreps (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-713?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jay Kreps updated AVRO-713:
---------------------------

    Attachment: avro-tostring-json-fix.diff

Here is a patch that fixes the enum issue. It also includes proper escaping of JSON strings (i.e. so if the string contains a quote the json string isn't prematurely terminated. The escaping code is adapted from http://code.google.com/p/json-simple/source/browse/trunk/src/org/json/simple/JSONValue.java#227.

Copying the escaping code to write directly to the StringBuilder seems better than using Jackson, since I think with Jackson we would have to instantiate a bunch of objects and double-copy the string.

> GenericRecord.toString can produce invalid JSON
> -----------------------------------------------
>
>                 Key: AVRO-713
>                 URL: https://issues.apache.org/jira/browse/AVRO-713
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.4.1
>            Reporter: Jay Kreps
>         Attachments: avro-tostring-json-fix.diff
>
>
> The GenericData.toString method can produce invalid JSON. The problem is that enums are printed without quotes, as in
> {"emum_field":a}
> instead of 
> {"enum_field":"a"}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (AVRO-713) GenericRecord.toString can produce invalid JSON

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-713?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doug Cutting resolved AVRO-713.
-------------------------------

       Resolution: Fixed
    Fix Version/s: 1.5.0
         Assignee: Jay Kreps
     Hadoop Flags: [Reviewed]

I committed this.  Thanks, Jay!

> GenericRecord.toString can produce invalid JSON
> -----------------------------------------------
>
>                 Key: AVRO-713
>                 URL: https://issues.apache.org/jira/browse/AVRO-713
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.4.1
>            Reporter: Jay Kreps
>            Assignee: Jay Kreps
>             Fix For: 1.5.0
>
>         Attachments: avro-tostring-json-fix.diff
>
>
> The GenericData.toString method can produce invalid JSON. The problem is that enums are printed without quotes, as in
> {"emum_field":a}
> instead of 
> {"enum_field":"a"}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.