Answers.Body: <p>As per the <a href="https://craftcms.com/docs/3.x/element-queries.html#advanced-element-queries" rel="nofollow noreferrer">docs</a>:</p>
  <blockquote>
  <p>Element queries are specialized query builders under the hood, so they
  support most of the same methods provided by craft\db\Query.</p>
  </blockquote>
  <p>...So, in your case you could use <code>select()</code> to only select the fields you want:</p>
  <p><code>{% set services = craft.entries.section('services').asArray().select(['title','id','url']).all() %}</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-31T03:03:38.767Z
Answers.Text: Thanks! I knew this was possible. The `.select()` example on the page just takes you to the Yii docs. I ws adding select() before the asArray().
Answers.UserDisplayName: casey
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-28T08:05:13.033Z
Answers.LastActivityDate: 2020-08-28T08:05:13.033Z
Answers.UserDisplayName: James Smith
Answers.Body: <p>I ended up using:</p>
  <pre><code>{% set svcarray = craft.entries.section('services').select('content.id,content.title,elements_sites.slug,elements_sites.uri').asArray().all() %}
  </code></pre>
  <p>For whatever reason this ended up throwing an exception:</p>
  <pre><code>{% set svcarray = craft.entries.section('services').asArray().select(['title','id','url']).all() %}
  </code></pre>
  <blockquote>
  <p>Integrity constraint violation: 1052 Column 'id' in field list is
  ambiguous</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-31T03:12:01.393Z
Answers.LastActivityDate: 2020-08-31T03:28:11.160Z
Answers.LastEditDate: 2020-08-31T03:28:11.160Z
Answers.UserDisplayName: casey
Body: <p>I'm building a JSON array of several thousand entries using the following entries query:</p>
  <p><code>{% set services = craft.entries.section('services').asArray().all() %}</code></p>
  <p>The problem is there some private info is visible within the JSON and can be viewed in the browser source (not to mention the result is HUGE.</p>
  <p><code>let services = {{ services | json_encode | raw }};</code></p>
  <p>Is there a parameter similar to <a href="https://craftcms.com/docs/3.x/element-queries.html#ids" rel="nofollow noreferrer">ids()</a> where I can specify only the title, url, and ID?
  If not, what's the best Twig way to reduce this array to what I'm looking for?</p>
  
Tags: <templating><entries><json>
Title: Limiting entries object when using as json_encode
ThreadText: # Limiting entries object when using as json_encode
  
  (Asked by: username_0 on 2020-08-28)
  
  I'm building a JSON array of several thousand entries using the following entries query:
  
  `{% set services = craft.entries.section('services').asArray().all() %}`
  
  The problem is there some private info is visible within the JSON and can be viewed in the browser source (not to mention the result is HUGE.
  
  `let services = {{ services | json_encode | raw }};`
  
  Is there a parameter similar to [ids()](https://craftcms.com/docs/3.x/element-queries.html#ids) where I can specify only the title, url, and ID?
  If not, what's the best Twig way to reduce this array to what I'm looking for?
  
  **Tags:** templating, entries, json
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-08-28. Score: 3
  
  As per the [docs](https://craftcms.com/docs/3.x/element-queries.html#advanced-element-queries):
  
  > Element queries are specialized query builders under the hood, so they
  > support most of the same methods provided by craft\db\Query.
  
  ...So, in your case you could use `select()` to only select the fields you want:
  
  `{% set services = craft.entries.section('services').asArray().select(['title','id','url']).all() %}`
  
  > **Comments:**
  > **username_0**: Thanks! I knew this was possible. The `.select()` example on the page just takes you to the Yii docs. I ws adding select() before the asArray().  
  
  ---
  
  ### Answer by username_0 on 2020-08-31. Score: 1
  
  I ended up using:
  
  ```
  {% set svcarray = craft.entries.section('services').select('content.id,content.title,elements_sites.slug,elements_sites.uri').asArray().all() %}
  
  ```
  
  For whatever reason this ended up throwing an exception:
  
  ```
  {% set svcarray = craft.entries.section('services').asArray().select(['title','id','url']).all() %}
  
  ```
  
  > Integrity constraint violation: 1052 Column 'id' in field list is
  > ambiguous
  
  
  ---
  
  