Skip to navigation

This reference provides the sample string utilities in Liquid expressions.

to_json

Convert the format from hash to JSON.

{{ Data.Workflow | to_json }}
{% comment %} {"ExecutionDate":"2021-01-01","LastRunDate":"2020-12-31"...} {% endcomment %}

parse_json

Convert the format from JSON to hash.

{% assign input = '{"name":"INV-100","balance":1}' | parse_json %}
{{ input }}
{% comment %} {"name"=>"INV-100","balance"=>1} {% endcomment %}

string_escape

Escape special characters.

{{ '\abc\' | string_escape }}
{% comment %} \\abc\\ {% endcomment %}

to_xml

Convert the format from hash to XML.

{{ Data.Workflow | to_xml}}
{% comment %} <?xml version="1.0" encoding="UTF-8"?><hash><ExecutionDate>2021-01-01</ExecutionDate>...</hash> {% endcomment %}

regex

Return array of strings that match the regular expression.

Parameters: input, regular expression, operation[‘match_first’, ‘match_all’]

{{ 'INV-100,INV-101' | regex: 'INV-\d+', 'match_first' }}
{% comment %} ["INV-100"] {% endcomment %}
{{ 'INV-100,INV-101' | regex: 'INV-\d+', 'match_all' }}
{% comment %} ["INV-100","INV-101"] {% endcomment %}

input_byte_8x

Add spaces to a string to reach the byte mark.

{{ 'abc' | input_byte_8x }}
{% comment %} 'abc ' {% endcomment %}