1 Reply Latest reply on Sep 29, 2012 4:25 PM by 965123

    Reading JSON thru web service into POJOs annotated for Hibernate

      I am reading the following json through a web service. Is there a way to read the json into three appropriate POJOs? The POJOs are generated by hibernate and are used to communicate to the database.

      Basically I need to read the person json into a Person POJO, the pets json into a set of Pet POJOs, and the toy json into a set of Toy POJOs.

      The JSON

      "person":{"first_name":"John", "last_name":"Smith"},
      "pets":[{"species":"dog", "name":"Adama"}, {"species":"cat", "name":"Benton"} ],
      "toys":[{"car":"corvet", "color":"black"}, {"action_figure":"hancock", "height":"1ft"} ]

      The Web Service

      public Representation readForm(Representation representation) {
      try {
      Person aPerson = …
      Set<Pet> petSet = …
      Set<Toy> toySet = ...


      Now of course I know I can use Jackson to convert JSON to POJO. But the problem is that the POJOs in question are annotated (EJB) for hibernate. So is it acceptable to mix and match annotations like that?