Code example for JsonParser

Methods: parse

0
    public MessageBeanDeserializer() { 
        parser = new JsonParser();
    } 
 
    public Message deserializeMessageBean(String jsonMessage) {
        JsonObject j = (JsonObject) parser.parse(jsonMessage);
        Message messageBean = new Message();
        messageBean.setAction(j.get("action").getAsString());
        messageBean.setType(j.get("type").getAsString());
        messageBean.setObject(j.get("object").toString());
        return messageBean;
    } 
} 
Experience pair programming with AI  Get Codota for Java