title: How do I extract specific attributes from JSON using copy(JSON.stringify(Object.entries while filtering out unneeded attributes in chrome console?
body: <p>The data I'm looking to process is a form of web-based game data communicated through JSON. I'm trying to do statistical analysis on correlations between let's say attributes <code>api_ship_id</code> and <code>api_lv</code>. I was following a <a href="https://kancolle-fleetanalysis.firebaseapp.com/#/" rel="nofollow noreferrer">Tutorial</a> (Mostly in Japanese) on how to export some JSON files with a chrome plugin. On the other hand, I have a chromium-based web browser that supports similar JSON export but has a slightly different structure. The code this tutorial provided as was</p>
  <pre><code>copy(JSON.stringify(Object.entries(temp1.model.ship._map).map(([, v]) =&gt; v._o).filter(v =&gt; v.api_locked), ['api_ship_id', 'api_lv', 'api_kyouka', 'api_exp']))
  </code></pre>
  <p>but my chromium-based browser have trouble parsing this JSON when going filter.</p>
  <blockquote>
  <p>Uncaught TypeError: Cannot read property 'api_locked' of undefined.</p>
  </blockquote>
  <p>tl;dr: The 4 catagories I want are
  <code>['api_ship_id', 'api_lv', 'api_kyouka', 'api_exp']</code></p>
  <p>JSON:</p>
  <pre><code>{&quot;1&quot;: {
      &quot;api_id&quot;: 1,
      &quot;api_sortno&quot;: 1337,
      &quot;api_ship_id&quot;: 237,
      &quot;api_lv&quot;: 70,
      &quot;api_exp&quot;: [
          274115,
          885,
          91
      ],
      &quot;api_nowhp&quot;: 30,
      &quot;api_maxhp&quot;: 30,
      &quot;api_soku&quot;: 10,
      &quot;api_leng&quot;: 1,
      &quot;api_slot&quot;: [
          -1,
          -1,
          -1,
          -1,
          -1
      ],
      &quot;api_onslot&quot;: [
          0,
          0,
          0,
          0,
          0
      ],
      &quot;api_slot_ex&quot;: 0,
      &quot;api_kyouka&quot;: [
          37,
          51,
          34,
          36,
          0,
          0,
          0
      ],
      &quot;api_backs&quot;: 4,
      &quot;api_fuel&quot;: 15,
      &quot;api_bull&quot;: 20,
      &quot;api_slotnum&quot;: 3,
      &quot;api_ndock_time&quot;: 0,
      &quot;api_ndock_item&quot;: [
          0,
          0
      ],
      &quot;api_srate&quot;: 4,
      &quot;api_cond&quot;: 49,
      &quot;api_karyoku&quot;: [
          49,
          49
      ],
      &quot;api_raisou&quot;: [
          79,
          79
      ],
      &quot;api_taiku&quot;: [
          49,
          49
      ],
      &quot;api_soukou&quot;: [
          49,
          49
      ],
      &quot;api_kaihi&quot;: [
          76,
          89
      ],
      &quot;api_taisen&quot;: [
          48,
          59
      ],
      &quot;api_sakuteki&quot;: [
          29,
          39
      ],
      &quot;api_lucky&quot;: [
          12,
          59
      ],
      &quot;api_locked&quot;: 1,
      &quot;api_locked_equip&quot;: 0
  },
  &quot;2&quot;: {
      &quot;api_id&quot;: 2,
      &quot;api_sortno&quot;: 1350,
      &quot;api_ship_id&quot;: 250,
      &quot;api_lv&quot;: 29,
      &quot;api_exp&quot;: [
          40635,
          2865,
          1
      ],
      &quot;api_nowhp&quot;: 31,
      &quot;api_maxhp&quot;: 31,
      &quot;api_soku&quot;: 10,
      &quot;api_leng&quot;: 1,
      &quot;api_slot&quot;: [
          1921,
          356,
          -1,
          -1,
          -1
      ],
      &quot;api_onslot&quot;: [
          0,
          0,
          0,
          0,
          0
      ],
      &quot;api_slot_ex&quot;: 0,
      &quot;api_kyouka&quot;: [
          22,
          37,
          15,
          19,
          0,
          0,
          0
      ],
      &quot;api_backs&quot;: 4,
      &quot;api_fuel&quot;: 15,
      &quot;api_bull&quot;: 20,
      &quot;api_slotnum&quot;: 3,
      &quot;api_ndock_time&quot;: 0,
      &quot;api_ndock_item&quot;: [
          0,
          0
      ],
      &quot;api_srate&quot;: 2,
      &quot;api_cond&quot;: 73,
      &quot;api_karyoku&quot;: [
          36,
          49
      ],
      &quot;api_raisou&quot;: [
          65,
          79
      ],
      &quot;api_taiku&quot;: [
          38,
          49
      ],
      &quot;api_soukou&quot;: [
          33,
          49
      ],
      &quot;api_kaihi&quot;: [
          58,
          89
      ],
      &quot;api_taisen&quot;: [
          34,
          59
      ],
      &quot;api_sakuteki&quot;: [
          17,
          39
      ],
      &quot;api_lucky&quot;: [
          12,
          59
      ],
      &quot;api_locked&quot;: 1,
      &quot;api_locked_equip&quot;: 0
  },
  &quot;3&quot;: {
      &quot;api_id&quot;: 3,
      &quot;api_sortno&quot;: 1302,
      &quot;api_ship_id&quot;: 202,
      &quot;api_lv&quot;: 30,
      &quot;api_exp&quot;: [
          43597,
          2903,
          3
      ],
      &quot;api_nowhp&quot;: 30,
      &quot;api_maxhp&quot;: 30,
      &quot;api_soku&quot;: 10,
      &quot;api_leng&quot;: 1,
      &quot;api_slot&quot;: [
          2131,
          5074,
          -1,
          -1,
          -1
      ],
      &quot;api_onslot&quot;: [
          0,
          0,
          0,
          0,
          0
      ],
      &quot;api_slot_ex&quot;: 0,
      &quot;api_kyouka&quot;: [
          18,
          27,
          16,
          17,
          0,
          0,
          0
      ],
      &quot;api_backs&quot;: 4,
      &quot;api_fuel&quot;: 15,
      &quot;api_bull&quot;: 20,
      &quot;api_slotnum&quot;: 3,
      &quot;api_ndock_time&quot;: 0,
      &quot;api_ndock_item&quot;: [
          0,
          0
      ],
      &quot;api_srate&quot;: 2,
      &quot;api_cond&quot;: 61,
      &quot;api_karyoku&quot;: [
          32,
          49
      ],
      &quot;api_raisou&quot;: [
          62,
          79
      ],
      &quot;api_taiku&quot;: [
          32,
          49
      ],
      &quot;api_soukou&quot;: [
          30,
          49
      ],
      &quot;api_kaihi&quot;: [
          60,
          89
      ],
      &quot;api_taisen&quot;: [
          34,
          59
      ],
      &quot;api_sakuteki&quot;: [
          16,
          39
      ],
      &quot;api_lucky&quot;: [
          12,
          49
      ],
      &quot;api_locked&quot;: 1,
      &quot;api_locked_equip&quot;: 0
  }}
  </code></pre>
  <p>What I've tried</p>
  <pre><code>copy(JSON.stringify(Object.entries(temp2).map(([, v]) =&gt; v._o), ['api_ship_id', 'api_lv', 'api_kyouka', 'api_exp']))
  </code></pre>
  <p>Result: <code>undefined</code></p>
  <p>Ideal results:</p>
  <pre><code>{&quot;api_ship_id&quot;: 237,&quot;api_lv&quot;: 70,&quot;api_kyouka&quot;: [37,51,34,36,0,0,0],&quot;api_exp&quot;: [40635,2865,1],}
  {&quot;api_ship_id&quot;: 238,&quot;api_lv&quot;: 68,&quot;api_kyouka&quot;: [30,0,4,6,0,0,0],&quot;api_exp&quot;: [565,285,1],}
  </code></pre>