<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>

CC BY-SA 4.0
2019-04-15T16:10:25.923Z
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!
sunscreem
CC BY-SA 4.0
2019-04-15T15:07:54.163Z
2019-04-15T15:29:41.163Z
2019-04-15T15:29:41.163Z
Robin Schambach
<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>

<templating><vue>
How to get an element query into json (for vue) without extra data?
# 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 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
{% 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!  

---

