title: How to receive a byte array inside a JSON
body: <p>I'm trying to receive a PDF from server that will be wrapped inside a JSON.</p>
  
  <p>If I am only sending a byte array of the pdf to the front-end, I can read it properly by setting <code>responseType</code> to <code>arraybuffer</code>, then I can download the PDF by:</p>
  
  <pre><code>var blob = new Blob([data], { type: application/pdf});
      if ($window.navigator &amp;&amp; $window.navigator.msSaveOrOpenBlob) {
          $window.navigator.msSaveOrOpenBlob(blob);
      } else {
          var a = document.createElement("a");
          document.body.appendChild(a);
          var fileURL = URL.createObjectURL(blob);
          a.href = fileURL;
          a.download = fileName;
          a.click();
      }
  }
  </code></pre>
  
  <p>However when the server tries to send JSON with the bytearray inside, if I set the <code>responseType</code> to <code>JSON</code>, then I wont be able to convert the blob. But if I set <code>responseType</code> to <code>arrayBuffer</code>, I will get an Array of arrayBuffer, how do I convert it to JSON while still be able to extract the PDF afterward:</p>
  
  <p>The JSON I'm receiving is in the form:</p>
  
  <pre><code>{
    result: true,
    value: &lt;the pdf byte array&gt;,
    errorMessage: null
  }
  </code></pre>