Announcement Announcement Module
Collapse
No announcement yet.
Roo and Json and converting messages Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Roo and Json and converting messages

    Hi folks,

    II know this isn;t the correct place for this post but I've been trying to solve this for hours. l've added RooJson annotation to an object I've created and want to process the following input:

    Code:
    {"inboundDataNotification": {
    "callbackData": "12345",
    "inboundData": {
    "message": "Hello World",
    "messageId": "mes1234"
    }
    }}
    Using the following method (I'm only interested in the inboundData part as the rest is really just a wrapper:

    Code:
    import flexjson.JSONDeserializer;
    
    @RooJavaBean @RooToString @RooJson(fromJsonArrayMethod="", toJsonArrayMethod="", toJsonMethod="") public class InboundData {
    
    private String messageId;
    
    private String message;
    
    public static InboundSMSMessage fromJsonToInboundSMSMessage(String
    json) { 
    return new JSONDeserializer().use(null, InboundSMSMessage.class).deserialize(json); }
    }
    All fields are null after this method is invoked. Any ideas what to change here?

    /Mark

  • #2
    I seems your Json document expects nested hierarchies (or at least special callback handling), so this won't work. I would suggest you first use the toJson method and print out the result to see exactly how the Json document should be formed.

    Comment


    • #3
      Hi Stefan,

      I ended up creating a pojo hierarchy that matched the structure of json response and that seemed to do the trick. Have a lot of pojos hanging around now as a consequence.

      /Mark

      Comment


      • #4
        Roo uses FlexJson to map Json documents to object hierarchies so it is no surprise that you need to align both sides. You can of course customize your mappings anytime with a little extra code.

        Comment

        Working...
        X