Oddly enough, I didn't find this.
What's the simplest way to convert an object to a JSON string? (Edge cases like loops in the object graphs aren't of much interest to me. Let's find a solution to the simple case of class A that contains some objects of classes B,C,D and some primitives).
Basic collection support is a must.
Heh, I discovered/remembered what we are already using for this.
ObjectMapper from CodeHaus
The code looks like this - super simple:
Object obj = ...
String result = new ObjectMapper().writeValueAsString(obj);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With