Answers.Body: <p>You can use the <code>asArray</code> function to return arrays instead of elements</p>
  
  <pre class="lang-twig prettyprint-override"><code>{% set sections = craft
      .categories
      .group('teamCategory')
      .select(['title','elements.id','groupId'])
      .asArray()
      .all() 
  %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-15T16:10:25.923Z
Answers.Text: Nice. That's the ticket. I wonder why this approach never stood out for me. Maybe I need to go and read the docs again!
Answers.UserDisplayName: sunscreem
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-15T15:07:54.163Z
Answers.LastActivityDate: 2019-04-15T15:29:41.163Z
Answers.LastEditDate: 2019-04-15T15:29:41.163Z
Answers.UserDisplayName: Robin Schambach
Body: <p>Lets say I want to get a list of category names and ids and pass them into JSON (for vue.js).</p>
  
  <p>This is how I'm currently doing it:</p>
  
  <pre><code>{% set sections = craft.categories.group('teamCategory').select(['title','elements.id','groupId']).all() %}
  
  &lt;!-- My vue.js tag: --&gt;
  &lt;team :sections="{{ sections|json_encode() }}"&gt;&lt;/team&gt;
  </code></pre>
  
  <p>My problem is that I only want <code>title</code> and <code>id</code> to be passed to vue, but craft/twig is passing load and loads more data that forms part of the category object. </p>
  
  <p>Is there an easy way to just pass the array columns I need? </p>
  
Tags: <templating><vue>
Title: How to get an element query into json (for vue) without extra data?
ThreadText: # How to get an element query into json (for vue) without extra data?
  
  (Asked by: username_0 on 2019-04-15)
  
  Lets say I want to get a list of category names and ids and pass them into JSON (for vue.js).
  
  This is how I'm currently doing it:
  
  ```
  {% set sections = craft.categories.group('teamCategory').select(['title','elements.id','groupId']).all() %}
  
  <!-- My vue.js tag: -->
  <team :sections="{{ sections|json_encode() }}"></team>
  
  ```
  
  My problem is that I only want `title` and `id` to be passed to vue, but craft/twig is passing load and loads more data that forms part of the category object.
  
  Is there an easy way to just pass the array columns I need?
  
  **Tags:** templating, vue
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-04-15. Score: 1 | Accepted answer
  
  You can use the `asArray` function to return arrays instead of elements
  
  ```twig
  {% set sections = craft
      .categories
      .group('teamCategory')
      .select(['title','elements.id','groupId'])
      .asArray()
      .all() 
  %}
  
  ```
  
  > **Comments:**
  > **username_0**: Nice. That's the ticket. I wonder why this approach never stood out for me. Maybe I need to go and read the docs again!  
  
  ---
  
  