Hi Kant, The toString method of GenericRecord returns a JSON payload
without the type information.

Cheers!
Akshay

On Sun, 16 Jul 2017, 07:07 kant kodali, <[email protected]> wrote:

> Hi All,
>
> I have the following code.
>
> public String byte[] toJson(Schema schema, GenericRecord genericRecord) throws
> IOException {
>
>     ByteArrayOutputStream baos = new ByteArrayOutputStream();
>     DatumWriter<GenericRecord> writer = new GenericDatumWriter<>(schema);
>     JsonEncoder encoder = EncoderFactory.get().jsonEncoder(schema, baos);
>     writer.write(genericRecord, encoder);
>     encoder.flush();
>     baos.flush();
>     return new String(baos.toByteArray());
>
> }
>
>
> As you can see I am passing a Generic Record and I just need a String
>
> without the types.
>
> Right now The function above generates something like this
>
> {"NUM_7":{"double":0.0},"NUM_8":{"double":0.0}}
> What I need is this
>
> {"NUM_7":0.0},"NUM_8":0.0}
>
>
> Thanks!
>
>

Reply via email to