Jackson (API)
{{Short description|High-performance JSON processor for Java}}
{{Infobox software
| name = Jackson
| logo =
| screenshot =
| caption =
| developer =
| latest release version = 2.14.2
| latest release date = {{release date and age|2023|1|29}}
| operating system = Cross-platform
| programming language =
| license = Apache License 2.0
}}
{{Portal|Free and open-source software}}
In computing, Jackson is a high-performance JSON processor for Java. Its developers extol the combination of fast, correct, lightweight, and ergonomic attributes of the library.{{Cite web|url= http://wiki.fasterxml.com/JacksonHome |title= History |access-date= 12 February 2016 |website= FasterXML |url-status=dead |archive-url=https://web.archive.org/web/20160211195332/http://wiki.fasterxml.com/JacksonHome |archive-date= 11 February 2016 }}
{{Cite book
|title = The Jackson Cookbook
|last = Young |first = T.M.
|publisher = Leanpub
|year = 2013
}}
Implementation
Jackson provides multiple approaches to working with JSON, including using binding annotations on POJO classes for simple use cases.{{Cite book|title = Java Cookbook|last = Darwin|first = I.F.|edition = 3rd|publisher = O'Reilly|year = 2014|location = Sebastopol, USA|pages = 656–657}}
Usage example
Sample code for reading and writing with POJOs may look like the following:
public class ReadWriteJackson {
public static void main(String[] args) throws IOException {
ObjectMapper mapper = new ObjectMapper();
String jsonInput = "{\"id\":0,\"firstName\":\"Robin\",\"lastName\":\"Wilson\"}";
Person q = mapper.readValue(jsonInput, Person.class);
System.out.println("Read and parsed Person from JSON: " + q);
Person p = new Person("Roger", "Rabbit");
System.out.print("Person object " + p + " as JSON = ");
mapper.writeValue(System.out, p);
}
}
References
{{Reflist}}
External links
- {{github|FasterXML/jackson}}