forked from culturekings/shopify-json-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request culturekings#2 from culturekings/lazy-decode-tweaks
Formatting changes and add variable namespaces
- Loading branch information
Showing
2 changed files
with
12 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
{%- comment -%} | ||
This function is used when speed is important. | ||
It simply searches for key. | ||
The value of the key must be a simple array | ||
Usage : {% include 'json_lazy_decode' json: product.metafields.global.JAN key: 'three_sixty' %}{% assign three_sixty = jd__yield_1 %} | ||
This function is used when speed is important, it simply searches for key. | ||
The value of the key must be a simple array. | ||
Usage: | ||
{% include 'json_lazy_decode' json: product.metafields.global.JAN key: 'three_sixty' %}{% assign three_sixty = jld__yield_1 %} | ||
{%- endcomment -%} | ||
{%- assign key_quoted = key | append : '"' | prepend : '"' -%} | ||
{%- assign value = json | split: key_quoted -%} | ||
{%- assign value = value[1] | split: '[' -%} | ||
{%- assign value = value[1] | split: ']' -%} | ||
{%- assign value = value[0] | replace: '"', '' -%} | ||
{%- assign jd__yield_1 = value | split: ',' -%} | ||
{%- assign jld__key_quoted = key | append : '"' | prepend : '"' -%} | ||
{%- assign jld__value = json | split: jld__key_quoted -%} | ||
{%- assign jld__value = jld__value[1] | split: '[' -%} | ||
{%- assign jld__value = jld__value[1] | split: ']' -%} | ||
{%- assign jld__value = jld__value[0] | replace: '"', '' -%} | ||
{%- assign jld__yield_1 = jld__value | split: ',' -%} |