title: Adding property to JSON using Jackson
body: <p>So my <code>jsonStr</code> is this</p>
  
  <pre><code>[
      {
          "data": [
              {
                  "itemLabel": "Social Media",
                  "itemValue": 90
              },
              {
                  "itemLabel": "Blogs",
                  "itemValue": 30
              },
              {
                  "itemLabel": "Text Messaging",
                  "itemValue": 60
              },
              {
                  "itemLabel": "Email",
                  "itemValue": 90
              }
          ]
      }
  ]
  </code></pre>
  
  <p>I want to add a property after the <code>data</code> array like this</p>
  
  <pre><code>[
      {
          "data": [
              {
                  "itemLabel": "Social Media",
                  "itemValue": 90
              },
              {
                  "itemLabel": "Blogs",
                  "itemValue": 30
              },
              {
                  "itemLabel": "Text Messaging",
                  "itemValue": 60
              },
              {
                  "itemLabel": "Email",
                  "itemValue": 90
              }
          ],
          "label": "2007"
      }
  ]
  </code></pre>
  
  <p>Reading on here it says to do something like </p>
  
  <pre><code>ObjectMapper mapper = new ObjectMapper();
  JsonNode jsonNode = mapper.readTree(jsonStr);
  ((ObjectNode) jsonNode).put("label", "2007");
  
  String json = mapper.writeValueAsString(jsonNode);
  
  return json;
  </code></pre>
  
  <p>The problem is I keep getting an error </p>
  
  <pre><code>java.lang.ClassCastException: com.fasterxml.jackson.databind.node.ArrayNode cannot be cast to com.fasterxml.jackson.databind.node.ObjectNode
  </code></pre>
  
  <p>What am I doing wrong? I'm currently using Jackson-core 2.2.2</p>