Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-860

Invalid JSON when printing out records with unicode

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 1.5.1
    • None
    • java

    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.
      

      Attachments

        1. m.avro
          0.4 kB
          Miki Tebeka
        2. AVRO-860.diff
          6 kB
          Miki Tebeka
        3. AVRO-860.diff
          7 kB
          Miki Tebeka

        Issue Links

          Activity

            People

              tebeka Miki Tebeka
              tebeka Miki Tebeka
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: