Hello,

I am using Jersey Client w/ Jackson to parse JSON data coming back from 
external service.  I would like to reformat the output of JSON i am 
receiving to only the data I care about.
Is it possible to handle the following input JSON data in Jackson:

{
  "samples": {
    "hits": [
      {
        "type": "type-two",
        "source": {
          "id" : "ID_321-321",
          "name": "Two",
          "title": "TheTitle",
          "category": "toys",
          "sub-category": "games",
          "tags": [
            "animation",
            "television",
            "games"
          ],
        }
      },
      {
        "type": "type-one",
        "source": {
          "id": "ID_123-123",
          "name": "One",
          "title": "TheTitle",
          "description": "blah blah blah ",
          "caption": "blah" 
        }
      }
    ]
  }
}


Where 'hits' is a List of MyInterface:

public interface MyInterface {
 public String getId();
 public void setId( String id );
}


Where i have two implementations of MyInterface:

public One implements MyInterface {
 String id;
 String name;
 String title;
 String description;
 String caption;


 ....
}


public Two implements MyInterface {
 String id;
 String name;
 String title;
 String category;
 String sub_category;
 List<String> tags;


 ....
}


I would like to have a resultant JSON like:

{
    "hits": [
      {
          "id" : "ID_321-321",
          "type": "type-two",
          "name": "Two",
          "title": "TheTitle",
          "category": "toys",
          "sub-category": "games",
          "tags": [
            "animation",
            "television",
            "games"
          ]
      },
      {
          "id": "ID_123-123",
          "type": "type-one",
          "name": "One",
          "title": "TheTitle",
          "description": "blah blah blah ",
          "caption": "blah" 
      }
    ]
}


What is the best approach to handle the serialization/deserialization of 
this data?

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to