title: save Java Object to Redis as value
body: <p>I want to save a very complex java object to redis as a value. Therefore I have tried to convert this object to Json (gson lib) but it isn't working for my purpose (see other question: <a href="https://stackoverflow.com/questions/24820389/gson-java-lang-illegalargumentexception-class-xx-declares-multiple-json-field?noredirect=1#comment38532338_24820389">GSON java.lang.IllegalArgumentException: class &#39;xx&#39; declares multiple JSON fields named &#39;XX&#39; AND StackOverflowError</a>). </p>
  
  <p>I want to <strong>store/serialize</strong> this mentioned complex java object of an application to redis as a value and load back later to the complex java object (consindering the following comment: <a href="https://stackoverflow.com/questions/12279117/can-jedis-get-set-an-java-pojo/12355876#12355876">Can Jedis get/set an Java POJO?</a>). It is just for evaluation purpose.</p>
  
  <p>How can I accomplish to store this complex object (preferable with json conversion) to redis and back? Every comment would be helpful</p>
  
  <hr>
  
  <p>Update1: The converstion to json and back is working, but with futher process in the application the system is raising a <code>java.util.LinkedHashMap incompatible with XXX</code>.</p>
  
  <pre><code>  SuperclassExclusionStrategy ex = new SuperclassExclusionStrategy();
    Gson gson = new GsonBuilder().addDeserializationExclusionStrategy(ex).addSerializationExclusionStrategy(ex).create();
  
    String json = gson.toJson(daoResult);
  
    daoResultJson = gson.fromJson(json, JavaObject_DAOListResult.class);
  </code></pre>
  
  <p>There are some objects in the subclasses, which hasn't been converted back in the original state.</p>
  
  <hr>
  
  <p><strong>Solved</strong></p>
  
  <p>I have solved my problem in using another lib called <a href="https://code.google.com/p/json-io/" rel="nofollow noreferrer">json-io</a></p>
  
  <p>Now I can work perfectly fine with with my object. In Gson there were a lot of null properties whis were missing in the json string. With json-io the null properties were converted as well. Here is the solution:  </p>
  
  <pre><code> // convert daoResult to JSON
   jsonIO = JsonWriter.objectToJson(daoResult);
   // convert stored JSON to daoResult
   daoResultJson =  (DAOListResult) JsonReader.jsonToJava(jsonIO);
  </code></pre>