<p>Sounds like your options simply need to be JSON decoded. Unfortunately, Twig doesn't ship with a <code>json_decode</code> filter, so you'll need a plugin – there are <a href="https://straightupcraft.com/craft-plugins?q=json&amp;" rel="nofollow noreferrer">several that fit the bill over at StraightUpCraft</a>.</p>

<p>Using the <a href="https://straightupcraft.com/craft-plugins/json-decode-twig-filter" rel="nofollow noreferrer">JSON Decode Filter</a> plugin, here's how your code would look:</p>

<pre><code>{% set options = entry.optionsAndAccessoiries|json_decode %}
...
</code></pre>

CC BY-SA 3.0
2016-12-04T10:10:51.487Z
2016-12-04T10:10:51.487Z
Mats Mikkel Rummelhoff
<p>With FeedMe I'm importing some data and one of them I get is a complete array that is stored a plain text field.</p>

<p>This array is a bunch of car options what I want to add in a table like this:</p>

<pre><code>{% set options = entry.optionsAndAccessoiries %}

output {{ options }} = ["Achterbank in delen neerklapbaar","Airbag bestuurder","Airconditioning","Anti-slipregeling","Antiblokkeersysteem","Centrale deurvergrendeling afstandbediend","Elektrisch bedienbare ramen voor","Elektrisch verstelbare buitenspiegels","Getint glas","Hoofdsteunen achter","Hoofdsteunen voor","In hoogte verstelbare bestuurdersstoel","Metallic lak","Middenarmsteun voor","Mistlampen voor","Radio\/CD speler","Startonderbreker","Stoelverwarming bestuurder","Stoffen bekleding","Stuurbekrachtiging","Trekhaak","Verstelbaar stuurwiel"]

{% set items = options %}

 &lt;table&gt;
  {% for row in items|batch(3, 'No item') %}
  &lt;tr&gt;
    {% for column in row %}
    &lt;td&gt;{{ column }}&lt;/td&gt;
    {% endfor %}
  &lt;/tr&gt;
  {% endfor %}
&lt;/table&gt;
</code></pre>

<p>But this is causing an error:</p>

<pre><code>array_chunk() expects parameter 1 to be array, string given
</code></pre>

<p>Who can help me out to point me in the right direction?</p>

CC BY-SA 3.0
2016-12-04T02:15:51.317Z
When you `{{ options }}` you literally get the output that you displayed above?  i.e. square brackets and everything?
Brad Bell
CC BY-SA 3.0
2016-12-04T09:16:38.933Z
Yes correct. And when I copy/paste that to `{% set options = ["Achterbank in delen neerklapbaar","Airbag bestuurder","etc..."]` it works like a charm.
John Stevens
CC BY-SA 3.0
2016-12-04T09:43:29.590Z
This is not working:
`{% set opties = ["Achterbank in delen neerklapbaar","Airbag bestuurder","Airconditioning"] %}

                     {% set items = opties %}

                    <table>
                    {% for row in items|batch(3, 'No item') %}
                        <tr>
                            {% for column in row %}
                                <td>{{ column }}</td>
                            {% endfor %}
                        </tr>
                    {% endfor %}
                    </table>`
John Stevens
CC BY-SA 3.0
2016-12-04T09:45:52.367Z
While this is working:
`{% set items = ["Achterbank in delen neerklapbaar","Airbag bestuurder","Airconditioning"] %}

                    <table>
                    {% for row in items|batch(3, 'No item') %}
                        <tr>
                            {% for column in row %}
                                <td>{{ column }}</td>
                            {% endfor %}
                        </tr>
                    {% endfor %}
                    </table>`
John Stevens
<entrymodel><array><plugin-feedme>
How to convert this 'array'
# How to convert this 'array'

(Asked by: username_0 on 2016-12-04)

With FeedMe I'm importing some data and one of them I get is a complete array that is stored a plain text field.
This array is a bunch of car options what I want to add in a table like this:
{% set options = entry.optionsAndAccessoiries %}

output {{ options }} = ["Achterbank in delen neerklapbaar","Airbag bestuurder","Airconditioning","Anti-slipregeling","Antiblokkeersysteem","Centrale deurvergrendeling afstandbediend","Elektrisch bedienbare ramen voor","Elektrisch verstelbare buitenspiegels","Getint glas","Hoofdsteunen achter","Hoofdsteunen voor","In hoogte verstelbare bestuurdersstoel","Metallic lak","Middenarmsteun voor","Mistlampen voor","Radio\/CD speler","Startonderbreker","Stoelverwarming bestuurder","Stoffen bekleding","Stuurbekrachtiging","Trekhaak","Verstelbaar stuurwiel"]

{% set items = options %}

 
  {% for row in items|batch(3, 'No item') %}
  
    {% for column in row %}
    {{ column }}
    {% endfor %}
  
  {% endfor %}


But this is causing an error:
array_chunk() expects parameter 1 to be array, string given

Who can help me out to point me in the right direction?

**Tags:** entrymodel, array, plugin-feedme
> **Comments:**
> **username_1**: When you `{{ options }}` you literally get the output that you displayed above?  i.e. square brackets and everything?  
> **username_0**: Yes correct. And when I copy/paste that to `{% set options = ["Achterbank in delen neerklapbaar","Airbag bestuurder","etc..."]` it works like a charm.  
> **username_0**: This is not working: `{% set opties = ["Achterbank in delen neerklapbaar","Airbag bestuurder","Airconditioning"] %}                       {% set items = opties %}                      <table>                     {% for row in items|batch(3, 'No item') %}                         <tr>                             {% for column in row %}                                 <td>{{ column }}</td>                             {% endfor %}                         </tr>                     {% endfor %}                     </table>`  
> **username_0**: While this is working: `{% set items = ["Achterbank in delen neerklapbaar","Airbag bestuurder","Airconditioning"] %}                      <table>                     {% for row in items|batch(3, 'No item') %}                         <tr>                             {% for column in row %}                                 <td>{{ column }}</td>                             {% endfor %}                         </tr>                     {% endfor %}                     </table>`  

---

## 1 answers

### Answer by username_2 on 2016-12-04. Score: 2 | Accepted answer

Sounds like your options simply need to be JSON decoded. Unfortunately, Twig doesn't ship with a json_decode filter, so you'll need a plugin – there are several that fit the bill over at StraightUpCraft.
Using the JSON Decode Filter plugin, here's how your code would look:
{% set options = entry.optionsAndAccessoiries|json_decode %}
...


---

