public HashMap<String, String> unserializeMessage(final String infosJsonFromTable)
{
if (JSONUtils.mayBeJSON(infosJsonFromTable))
{
JSONObject jsonObject = (JSONObject) JSONSerializer.toJSON(infosJsonFromTable);
JsonConfig config = new JsonConfig();
config.setRootClass(java.util.HashMap.class);
return (HashMap<String, String>) JSONSerializer.toJava(jsonObject, config);
}
//Si le contenu n'est pas une JSONString valide on s'assure de renvoyer qd meme une HashMap
HashMap<String, String> map = new HashMap<String, String>();
map.put("info", infosJsonFromTable);
return map;
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
public String serializeMessage(final HashMap<String, String> message)
{
JSONObject jsonObject = (JSONObject) JSONSerializer.toJSON(message);
return jsonObject.toString();
}
public HashMap<String, String> unserializeMessage(final String infosJsonFromTable)
{
if (JSONUtils.mayBeJSON(infosJsonFromTable))
{
JSONObject jsonObject = (JSONObject) JSONSerializer.toJSON(infosJsonFromTable);
JsonConfig config = new JsonConfig();
config.setRootClass(java.util.HashMap.class);
return (HashMap<String, String>) JSONSerializer.toJava(jsonObject, config);
}
//Si le contenu n'est pas une JSONString valide on s'assure de renvoyer qd meme une HashMap
HashMap<String, String> map = new HashMap<String, String>();
map.put("info", infosJsonFromTable);
return map;
}