google / gson

A Java serialization/deserialization library to convert Java Objects into JSON and back
Apache License 2.0
23.26k stars 4.27k forks source link

Gson pretty printing #1569

Open iamakilan opened 5 years ago

iamakilan commented 5 years ago

I want the output for empty object or array like below "metadata": { },

but actual am getting "metadata": {},

help me to overcome this.

dotnetB commented 5 years ago

Try a zero

Larry E. Barton


From: iamakilan notifications@github.com Sent: Tuesday, August 27, 2019 1:15:56 AM To: google/gson gson@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [google/gson] Gson pretty printing (#1569)

I want the output for empty object or array like below "metadata": { },

but actual am getting "metadata": {},

help me to overcome this.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/google/gson/issues/1569?email_source=notifications&email_token=AM2ZTS6X4FDQCIAL4KDAS3LQGS2AZA5CNFSM4IP5FC2KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HHRPNBQ, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AM2ZTS6DMEMXELOCZCTTLGTQGS2AZANCNFSM4IP5FC2A.

Omega-Ariston commented 4 years ago

create a gson instance like this:

Gson gson = new GsonBuilder().setPrettyPrinting().create();