users@jersey.java.net

[Jersey] Unmarshalling JSON using MoxyJsonProvider

From: John Brooks <iresprite_at_gmail.com>
Date: Tue, 29 Jul 2014 20:21:16 -0400

Hi, all- I'm trying to get my head around how to take JSON and map it to an
object using MOXyJsonProvider. I'm using the Planetside 2 API for a toy
project using this page
<http://census.soe.com/get/ps2:v2/character/5428010618020694593> as my
test. I used the documentation to get me this far:

http://pastebin.com/jQ9LuCRe

So I can print my response successfully as a string, but I don't fully
understand how to write it to a POJO. I've seen a couple of examples of
unmarshalling JSON to an object, and it looks like I create a public class
that has members that map to the elements of the JSON array. (I got that
bit of information from Blaise Doughan's blog here
<http://blog.bdoughan.com/2013/07/eclipselink-moxy-and-java-api-for-json.html>
and
here
<http://blog.bdoughan.com/2012/03/moxy-as-your-jax-rs-json-provider_15.html>.
From what I can see, I create a class like so:

public class Character {
 private Character_list character_list;
private int returned;
private Timing timing;

}

With Character_list and Timing being classes that contain the necessary
members that map to the data I want, and so on. I *think* I'm on the right
track, but I'm missing one or two intuitive leaps and could use some help
here. Can someone explain how I get from where I am to being able to put
the resulting JSON string into an object?

Thanks, and sorry for all the rank beginner stuff here!

John