toString() to JSON with Eclipse

right click –> Source –> generate toString() –> Generated code fieldset –> Edit button –> New.. button –> give a name (ex. JSON) –> copy and paste this pattern:

{"${member.name()}":"${member.value}", "${otherMembers}"}

That’s it.

Hope this help!