If you don't want Avro's json encoding then don't use an Avro json encoder. Just use toString() directly on your POJO. If it's a generic, specific or reflect datum, toString() will generate valid json without any type annotation around values of unions.
So replace all of the above code with: String avroGeneratedJson = test.toString(); Doug On Wed, Apr 25, 2018 at 12:34 PM, amrishsintu <[email protected]> wrote: > I use below java code to convert to json. > > Schema schema = ReflectData.get().getSchema(Test.class); > DatumWriter<PartyResult> userDatumWriter = new > GenericDatumWriter<PartyResult>(schema); > > ByteArrayOutputStream stream = new ByteArrayOutputStream(); > JsonEncoder encoder = EncoderFactory.get().jsonEncoder(schema, stream); > userDatumWriter.write(test, encoder); // test is the reference of Test > class pojo > encoder.flush(); > String avroGeneratedJson = stream.toString(); > > RESULT : "familyName": { > "string": "Seils" > } > I am trying for - {"familyName": "Seils"} > > Help me to understand how can I use Json Encoding here. > > > > -- > Sent from: http://apache-avro.679487.n3.nabble.com/Avro-Users-f679479.html >
