title: PHP create a json response from php to look like stripe api result
body: <p>I need to create a json response to look like Stripe API response using PHP.
  This is the structure I want to get:</p>
  <p><code>{ &quot;body&quot;: &quot;{\n  \&quot;error\&quot;: \&quot;Please enter a valid secret key\&quot;,\n}\n&quot;, }</code></p>
  <p>This is the code I have so far:</p>
  <p>first I create the array:</p>
  <pre><code>class Error {
  
      public $errors = array(
          'body' =&gt; array( 'error' =&gt; false ),
      );
  
      if ($this-&gt;errors['body']['error'] === false) {
          $this-&gt;errors['body']['error'] = 'Please enter a valid secret key'
      }
      
      $resp = json_encode( $this-&gt;errors ) 
      echo wp_send_json( $resp );
  }
  </code></pre>
  <p>but the result I get is:
  json_encode result:</p>
  <pre><code>{&quot;body&quot;:{&quot;error&quot;:&quot;Please enter a valid secret key&quot;}}
  </code></pre>
  <p>echo wp_send_json( $resp ) result:</p>
  <pre><code>res = &quot;{\&quot;body\&quot;:{\&quot;error\&quot;:\&quot;Please enter a valid secret key\&quot;}}&quot;
  </code></pre>
  <p>I don't want the body to be encoded.
  What am I missing?</p>