Answers.Body: <p>So it seems that even although the Craft field is set to <code>number</code> it doesn't actually define a number.</p>
  
  <p>I changed the field from a regular Craft table field to a Super Table field and my <code>{{ donutData|json_encode }}</code> corrects spits out an array of numbers.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-18T11:38:35.277Z
Answers.LastActivityDate: 2018-12-18T11:38:35.277Z
Answers.UserDisplayName: Steven Grant
Body: <p>I'm trying to use a charting library within a Craft template.</p>
  
  <p>The chart expects an array of numbers that I'm building up from a table but I'm getting an array of strings instead.</p>
  
  <pre><code>{% set donutData = [] %}
  {% for p in block.donutValues %}
      {% set donutData = donutData|merge([
          p.value
      ]) %}
  {% endfor %}
  </code></pre>
  
  <p>and then if I do <code>{{ donutData|json_encode }}</code> I get an array of strings returned that my chart library can't interpret.</p>
  
  <p><code>value</code> is set to be a number field in the Craft table column so not sure why I'm getting a string returned.</p>
  
Tags: <array><merge><string><number>
Title: Replace quotes in an array
ThreadText: # Replace quotes in an array
  
  (Asked by: username_0 on 2018-12-18)
  
  I'm trying to use a charting library within a Craft template.
  
  The chart expects an array of numbers that I'm building up from a table but I'm getting an array of strings instead.
  
  ```
  {% set donutData = [] %}
  {% for p in block.donutValues %}
      {% set donutData = donutData|merge([
          p.value
      ]) %}
  {% endfor %}
  
  ```
  
  and then if I do `{{ donutData|json_encode }}` I get an array of strings returned that my chart library can't interpret.
  
  `value` is set to be a number field in the Craft table column so not sure why I'm getting a string returned.
  
  **Tags:** array, merge, string, number
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-12-18. Score: 1
  
  So it seems that even although the Craft field is set to `number` it doesn't actually define a number.
  
  I changed the field from a regular Craft table field to a Super Table field and my `{{ donutData|json_encode }}` corrects spits out an array of numbers.
  
  
  ---
  
  