Answers.Body: <p>Ended up working out a solution:</p>
  
  <pre><code>var myData = {{ craft.entries.section('sectionName').find() | prune(['title']) | json_encode() | raw  }};
      var myArray = $.makeArray(myData);
      var newArray = new Array();
      $.each( arr, function(key, value) {
          $.each(value, function(keyNew, valueNew){
              newArray.push(valueNew);
          });
      });
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-07T13:06:34.887Z
Answers.LastActivityDate: 2015-08-07T13:06:34.887Z
Answers.UserDisplayName: toffeejay
Body: <p>I am using the Craft Prune plugin (<a href="https://github.com/mattstauffer/craftcms-prune" rel="nofollow">https://github.com/mattstauffer/craftcms-prune</a>) to pull out a JSON array of entries from a section of my site with the aim of integrating the data into a typeahead search field as autocomplete data.</p>
  
  <p>The problem I seem to be having is that the JSON array structure needs to be simplified for use as a datasource with typeahead.</p>
  
  <p>So the current JSON data structure is:</p>
  
  <pre><code>[{"title":"Entry One Title"}, {"title":"Entry Two Title"}, {"title":"Entry Three Title"}]
  </code></pre>
  
  <p>What I actually need the structure to be is:</p>
  
  <pre><code>["Entry One Title", "Entry Two Title", "Entry Three Title"]
  </code></pre>
  
  <p>I have already tried using the jQuery $.each() function and the jQuery $.map() function but they both simply return an array of objects not a simple JS array.</p>
  
  <p>Any help appreciated.</p>
  
Tags: <javascript><array><json>
Title: Using Craft Prune - convert JSON Array of Objects to simple array
ThreadText: # Using Craft Prune - convert JSON Array of Objects to simple array
  
  (Asked by: username_0 on 2015-08-07)
  
  I am using the Craft Prune plugin (<https://github.com/mattstauffer/craftcms-prune>) to pull out a JSON array of entries from a section of my site with the aim of integrating the data into a typeahead search field as autocomplete data.
  
  The problem I seem to be having is that the JSON array structure needs to be simplified for use as a datasource with typeahead.
  
  So the current JSON data structure is:
  
  ```
  [{"title":"Entry One Title"}, {"title":"Entry Two Title"}, {"title":"Entry Three Title"}]
  
  ```
  
  What I actually need the structure to be is:
  
  ```
  ["Entry One Title", "Entry Two Title", "Entry Three Title"]
  
  ```
  
  I have already tried using the jQuery $.each() function and the jQuery $.map() function but they both simply return an array of objects not a simple JS array.
  
  Any help appreciated.
  
  **Tags:** javascript, array, json
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2015-08-07. Score: 2
  
  Ended up working out a solution:
  
  ```
  var myData = {{ craft.entries.section('sectionName').find() | prune(['title']) | json_encode() | raw  }};
      var myArray = $.makeArray(myData);
      var newArray = new Array();
      $.each( arr, function(key, value) {
          $.each(value, function(keyNew, valueNew){
              newArray.push(valueNew);
          });
      });
  
  ```
  
  
  ---
  
  