title: How to create a JSON object
body: <p>I am trying to create an JSON object out of a PHP array. The array looks like this:</p>
  <pre><code>$post_data = array('item_type_id' =&gt; $item_type,
      'string_key' =&gt; $string_key,
      'string_value' =&gt; $string_value,
      'string_extra' =&gt; $string_extra,
      'is_public' =&gt; $public,
      'is_public_for_contacts' =&gt; $public_contacts);
  </code></pre>
  <p>The code to encode the JSON look like this:</p>
  <pre><code>$post_data = json_encode($post_data);
  </code></pre>
  <p>The JSON file is supposed to look like this in the end:</p>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;item&quot;: {
          &quot;is_public_for_contacts&quot;: false,
          &quot;string_extra&quot;: &quot;100000583627394&quot;,
          &quot;string_value&quot;: &quot;value&quot;,
          &quot;string_key&quot;: &quot;key&quot;,
          &quot;is_public&quot;: true,
          &quot;item_type_id&quot;: 4,
          &quot;numeric_extra&quot;: 0
      }
  }
  </code></pre>
  <p>How can I encapsulate the created JSON code in the &quot;item&quot;: { JSON CODE HERE }.</p>