Taking an example, let’s assume you are using the below-mentioned JSON script to fetch details through the Content Feeds.

You will notice that the array “list_subscriptions” has multiple rows, and each row has multiple items present in it.

When using the below-mentioned JSON in the Content Feed, it would require us to write a Liquid Script code to fetch the date from the content feed.


Content Feed:


"list_subscriptions":[{"list_id":74158,"name":"Anil_naksh","status":"Unsubscribed","created_at":"2017-04-11T23:46:56.000-04:00","updated_at":"2017-12-13T11:27:50.000-05:00"},{"list_id":33075,"name":"colin 111","status":"Unsubscribed","created_at":"2017-04-12T16:00:14.000-04:00","updated_at":"2017-12-13T11:27:50.000-05:00"},{"list_id":74234,"name":"Shaun_Training_batch_new","status":"Unsubscribed","created_at":"2017-04-12T23:50:30.000-04:00","updated_at":"2017-12-13T11:27:50.000-05:00"},{"list_id":75505,"name":"testlistfottest","status":"Unsubscribed","created_at":"2017-05-02T14:42:26.000-04:00","updated_at":"2017-12-13T11:27:50.000-05:00"}]


Using the standard way to print the array would show the whole JSON bulk.

{{list_subscriptions}}


Result - 

{"list_id":74158,"name":"Anil_naksh","status":"Unsubscribed","created_at":"2017-04-11T23:46:56.000-04:00","updated_at":"2017-12-13T11:27:50.000-05:00"},{"list_id":33075,"name":"colin 111","status":"Unsubscribed","created_at":"2017-04-12T16:00:14.000-04:00","updated_at":"2017-12-13T11:27:50.000-05:00"},{"list_id":74234,"name":"Shaun_Training_batch_new","status":"Unsubscribed","created_at":"2017-04-12T23:50:30.000-04:00","updated_at":"2017-12-13T11:27:50.000-05:00"},{"list_id":75505,"name":"testlistfottest","status":"Unsubscribed","created_at":"2017-05-02T14:42:26.000-04:00","updated_at":"2017-12-13T11:27:50.000-05:00"}


If we want to print only a particular row within the array, for example, the 2nd row, the liquid script would be:

{{list_subscriptions[1]}}


Result - {"list_id":33075,"name":"colin 111","status":"Unsubscribed","created_at":"2017-04-12T16:00:14.000-04:00","updated_at":"2017-12-13T11:27:50.000-05:00"}


To fetch the List ID of a specific item, use the script given below:

{% assign xyz=list_subscription[0] | where:’list_id’%}

{{xyz.list_id}}


Result - 74158


As you would have observed, we assigned the value of the first item of array list_subscription to "xyz" and used the “where” filter to match and find the string “list_id”. The first item of the array is fetched using the [0]. To change the row from where you wish to print the "list_id" or any other item, simply change the number present in the square brackets (0 stands for the first item in the array).

 This is applicable to all the scenarios where you have multiple items in a row present in the array.


The example mentioned above is based on cases where you need to assign the value to a variable and then use the value further in your liquid scripting. If it is only about fetching and printing the values (without assigning the value to any variable), you may use the liquid script mentioned below:


{{list_subscription[0].list_id}}


This tag will show the same results as the first example without assigning the array values to a variable.