title: Convert JSON To Array Javascript
body: <p>I am currently receiving a JSON Object From the Server side of my application, the result is this</p>
  
  <pre><code>{"tags":"[{value: 2,label: 'Dubstep'},{value: 3,label: 'BoysIIMen'},{value: 4,label:'Sylenth1'}]"}
  </code></pre>
  
  <p>But then I don't really need the "tags" and the double quotes in the result.</p>
  
  <p>So what I want is an array representation of that JSON object</p>
  
  <p>therefore how would I convert this</p>
  
  <pre><code>{"tags":"[{value: 2,label: 'Dubstep'},{value: 3,label: 'BoysIIMen'},{value: 4,label:'Sylenth1'}]"}
  </code></pre>
  
  <p>to this</p>
  
  <pre><code>[{value: 2,label: 'Dubstep'},{value: 3,label: 'BoysIIMen'},{value: 4,label:'Sylenth1'}]
  </code></pre>
  
  <p>Here's the loop that creates the array</p>
  
  <pre><code>String k = "["; 
          List&lt;Tag&gt; tg = audioTaggingService.findTagsByName(q);
          for(int i = 0; i&lt;audioTaggingService.findTagsByName(q).size();i++){
              Tag t = tg.get(i);
              if(i == (tg.size() - 1)){
                  k+="{value: "+t.getId()+",label:'"+t.getName()+"'}";
              }else{
                  k+="{value: "+t.getId()+",label:'"+t.getName()+"'}";
              }
          }
          k+="]";
  </code></pre>
  
  <p>The result of the code above is this</p>
  
  <pre><code>[{value: 2,label: 'Dubstep'},{value: 3,label: 'BoysIIMen'},{value: 4,label:'Sylenth1'}]
  </code></pre>