Search code examples
javaandroidjsonpojo

How to Convert JSON to POJO class?


I checked the following json, it is valid, But http://www.jsonschema2pojo.org/ is not converting it into POJO object so I can fetch values from it, I need "nameValuePairs" object in following model. Please help. Thanks in advance

[
       "order-chat-1",
       {
          "nameValuePairs":{
             "chat":{
                "nameValuePairs":{
                   "id":19,
                   "order_id":6,
                   "sender_id":10,
                   "receiver_id":3,
                   "message":"Hi",
                   "is_read":0,
                   "created_at":"2018-10-19 16:23:28",
                   "updated_at":"2018-10-19 16:23:28",
                   "is_sender":false
                }
             },
             "message":"Hello from chef",
             "message_type":"Message",
             "is_sender":false
          }
       }
    ]

Solution

  • I worked with another technique to resolve this, I converted this Object to String through Gson() and after that with subString method I removed the first 16 characters and the last character of the newly created string, then I Converted that String to POJO Object.