Avro
  1. Avro
  2. AVRO-860

Invalid JSON when printing out records with unicode

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 1.5.1
    • Fix Version/s: None
    • Component/s: java
    • Labels:

      Description

      I have an avro file, that when printed returns invalid JSON.
      The code for iterating and printing is:

      
                  DatumReader<GenericRecord> reader = new GenericDatumReader<GenericRecord>();
                  DataFileReader<GenericRecord> dataFileReader =
                      new DataFileReader<GenericRecord>(data, reader);
      
                  while (dataFileReader.hasNext()) {
                      System.out.println(dataFileReader.next().toString());
                  }
      

      and the relevant JSON snippet is

          "description": "Move™ offers advertisers the opportunity to deliver messages to consumers at a time when consumers are making the biggest purchases of their lives\uMOVE™ OFFERS ADVERTISERS THE OPPORTUNITY TO DELIVER MESSAGES TO CONSUMERS AT A TIME WHEN CONSUMERS ARE MAKING THE BIGGEST PURCHASES OF THEIR LIVES—OR REMODELING, REDECORATING AND MAINTAINING THEIR MOST IMPORTANT ASSETS.or remodeling, redecorating and maintaining their most important assets.",
      

      (The \uMOVE is the problematic part).

      However if I do:

                      GenericRecord record = dataFileReader.next();
                      Utf8 desc = (Utf8)record.get("description");
                      System.out.println(desc);
      

      Then I get

      Move™ offers advertisers the opportunity to deliver messages to consumers at a time when consumers are making the biggest purchases of their lives—or remodeling, redecorating and maintaining their most important assets.
      
      1. AVRO-860.diff
        7 kB
        Miki Tebeka
      2. AVRO-860.diff
        6 kB
        Miki Tebeka
      3. m.avro
        0.4 kB
        Miki Tebeka

        Issue Links

          Activity

          No work has yet been logged on this issue.

            People

            • Assignee:
              Miki Tebeka
              Reporter:
              Miki Tebeka
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development