title: Store object as attribute in json
body: <p>I am trying to make a simple console farm game using Java and JSON. I have a player stored in json in the following format:</p>
  <pre><code>{
    &quot;coins&quot;:5,
    &quot;name&quot;:&quot;playerName&quot;,
    &quot;inventory&quot;:{
       some inventory items...
    }
  }
  </code></pre>
  <p>But now I want to save a farm object as attribute of this player in such a way:</p>
  <pre><code>{
    &quot;coins&quot;:5,
    &quot;name&quot;:&quot;playerName&quot;,
    &quot;inventory&quot;:{
       some inventory items...
    },
    &quot;Farm&quot;: {
        &quot;capacity&quot;: 1,
        &quot;plantedSeeds&quot;: HashMap&lt;Integer, VegetableItem&gt; plantedSeeds
      }
  }
  </code></pre>
  <p>Does anyone have any idea how I can save my player in this way using Java and Jackson?
  Thanks!</p>
  <p><strong>UPDATE</strong></p>
  <p>I figured it out,
  i simply needed to create a seperate JSONObject, store all the values I wanted in that object, and then add the JSONObject as the attribute for the player object</p>