title: How to map an object stream to a specific type
body: <p>I have a <code>JSONArray</code> of objects, and I want to map each object to a <code>JSONObject</code>.</p>
  
  <p>I tried:</p>
  
  <pre><code>JSONArray array; //my json array
  array.stream().map(obj -&gt; (JSONObject) obj).forEach((JSONObject prof) -&gt; {
      //code
  });
  </code></pre>
  
  <p>However the type is already encapsulated by <code>Object</code> and thus I cannot seem to cast it down. How can I achieve this with Java 8 streams?</p>