title: How to convert string to array in react js?
body: <p>I have a JSON object that I cannot handle without
  <code>Uncaught SyntaxError: Unexpected token o in JSON at position 1</code>.</p>
  <p>So i made a string out of it
  <code>var array = JSON.stringify(this.props.user);</code></p>
  <p>Now that string has the format I neet to loop through it / to use map function
  <strong>BUT it is a string</strong>. How can I bring this string into an valid array to be able to loop through it?</p>
  <p>What I have as JSON object (copied from Chrome, typeof(..) returns object):</p>
  <pre><code>0:
  avatar: &quot;/media/dog_default_l.png&quot;
  birthday: &quot;2020-09-14&quot;
  user_settings: [&quot;P26&quot;]
  name: &quot;Huso&quot;
  gesellig: true
  verspielt: true
  __proto__: Object
  1:
  avatar: &quot;/media/dog_default_l.png&quot;
  birthday: &quot;2012-04-24&quot;
  user_settings: (2) [&quot;A9&quot;, &quot;B5&quot;]
  name: &quot;Medo&quot;
  gesellig: true
  verspielt: false
  __proto__: Object
  length: 2
  __proto__: Array(0)
  </code></pre>
  <p>This object as string (copied from console.log):</p>
  <pre><code>[{&quot;name&quot;:&quot;Huso&quot;,&quot;birthday&quot;:&quot;2020-09-14&quot;,&quot;gesellig&quot;:true,&quot;verspielt&quot;:true,&quot;avatar&quot;:&quot;/media/dog_default_l.png&quot;,&quot;user_settings&quot;:[&quot;P26&quot;]},{&quot;name&quot;:&quot;Medo&quot;,&quot;birthday&quot;:&quot;2012-04-24&quot;,&quot;gesellig&quot;:true,&quot;verspielt&quot;:false,&quot;avatar&quot;:&quot;/media/dog_default_l.png&quot;,&quot;user_settings&quot;:[&quot;A9&quot;,&quot;B5&quot;]}]
  </code></pre>
  <p>What I need is an array (to be able to loop through):</p>
  <pre><code>users: [
          { avatar: '/media/dog_default_l.png',
            birthday: '2020-09-14',
            name: 'Huso',
            gesellig: true,
            verspielt: true,
            user_settings: [
              {settings: 'P26'},
            ],
          },
          { avatar: '/media/dog_default_l.png',
            birthday: '2012-04-24',
            name: 'Medo',
            gesellig: true,
            verspielt: false,
            user_settings: [
              {settings: 'A9'},
              {settings: 'B5'},
            ],
          },
        ],
  </code></pre>
  <p>Object.entries, Object.keys etc. on the JSON object return or {} or nothing.
  I don't know if there is a way of getting this object looped?
  <strong>I'm really stuck and hope someone has a solution that works.</strong>
  This question is related to <a href="https://stackoverflow.com/questions/64243563/how-to-map-json-response-object-with-nested-array-to-state/64263353#64263353">How to map JSON response object with nested array to state</a> since nobody answers there.</p>