Jodd JSON
JavaScript Object Notation (aka JSON) is a very popular lightweight data-interchange format. Jodd JSON is a lightweight library for (de)serializing Java objects into and from JSON.
Before you say: "Yet another one?", please check what makes Jodd JSON unique. The power of the library is its control over the process of serialization and parsing; ease of use and great performances.

Quick Start

Let's see how to serialize:
1
Book book = new Book();
2
book.setName("Jodd in Action);
3
book.setYear(2018);
4
book.setAuthors(List.of(new Author("Igor")));
5
6
String json = JsonSerializer.create()
7
.include("authors")
8
.serialize(book);
Copied!
The resulting JSON may look like this:
1
{
2
"name" : "Jodd In Action",
3
"year" : 2018,
4
"authors" : [
5
{ "firstName" : "Igor" }
6
]
7
}
Copied!
Parse the JSON back to Java:
1
Book book2 = new JsonParser()
2
.parse(json, Book.class);
Copied!
Pretty simple, right? But don't get blinded by the simplicity, Jodd JSON is pretty powerful. Did I mention it is one of the fastest JSON frameworks out there?

Main features

  • simple syntax and fluent interface,
  • lazy parser that is super fast,
  • annotations for better conversion control,
  • convenient JSONObject and JSONArray classes,
  • powerful exclusion and inclusion rules,
  • serializer definition for types,
  • the only library that can handle any number size,
  • pretty formatting of the JSON output,
  • loose, more forgiving, parsing mode,
  • ways to address the keys and values of the Maps
  • flexible fine-tuning,
  • and more…

License

The code is released under the BSD-2-Clause license. It has a minimal set of dependencies with the same or similarly open license, so you should be able to use it in any project and for any purpose.
Last modified 1yr ago
Export as PDF
Copy link