Lava Example - 61 | Rock Community

Lava Example - 33


Prompt

Line 1 of this template has a comma-separated list of animals.

Turn this text into an array and use the | ToJSON filter to display the result on the page

You can modify the text on line 1 to experiment with the different filter parameters too:

Parameters for Split filter:
    Pattern Remove Empty (default: false) Maximum Array Size (default: unlimited)

(Note: If you use the

 element it will format the JSON nicely on the page.)

Initial Code
{% assign list = 'Boar,Dog,Rhino' %}
{{ list }}
Solution Lava
{% assign list = 'Boar,Dog,Rhino' %}
{% assign array = list | Split:',' %}
<pre>{{ array | ToJSON }}</pre>