Reputation: 1830
I have now simple client application which uses JSON/REST communication. It was simple, just include some org.json in my project, and use the API:
import org.json.JSONObject;
import org.json.JSONException;
JSONObject jo = new JSONObject();
try {
jo.put("User", "John");
jo.put("Order", "Pizza");
} catch (JSONException e) {
e.printStackTrace();
}
jo.toString();
I would like to migrate this approach to Jackson. How to do that with simple steps? Thanks.
NOTE: I don't really need instruction "how to add lib to project". I would like information what libs I need to do an object-to-JSON and JSON-to-object, and how can I use a magic of Jackson in real life example.
Upvotes: 0
Views: 1515
Reputation: 489
The main advantage of Jackson over the standard org.json api is its data-binding capabilites (meaning the ability to convert json directly into your java objects without having to manually select each parameter and assign it to an object property). For that you'll need jackson-annotations and jackson-databind in addition to jackson-core. You can put them all into a new library (and you can put in source packages (for added debugging features) and javadoc packages (for inline help)), and then include the library in your project.
Upvotes: 0
Reputation: 68715
Add the jackson.jar in your project in netbeans by doing:
File -> Project Properties -> Libraries -> Run-Time Libraries
Upvotes: 2