From 7843f60d5b378dd1552dda6d5c4984886a52455e Mon Sep 17 00:00:00 2001 From: Joe Refoy Date: Wed, 1 Mar 2017 12:30:05 +1000 Subject: [PATCH 1/3] Formatting changes and add variable namespaces --- json_lazy_decode.liquid | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/json_lazy_decode.liquid b/json_lazy_decode.liquid index 7168595..d282f6b 100644 --- a/json_lazy_decode.liquid +++ b/json_lazy_decode.liquid @@ -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 = jd__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: ',' -%} \ No newline at end of file +{%- 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: ',' -%} From c168799b2f7230cc1a7dc4e392e3eb34726d5d15 Mon Sep 17 00:00:00 2001 From: Joe Refoy Date: Wed, 1 Mar 2017 12:35:21 +1000 Subject: [PATCH 2/3] Update usage variable name --- json_lazy_decode.liquid | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json_lazy_decode.liquid b/json_lazy_decode.liquid index d282f6b..07b4b8a 100644 --- a/json_lazy_decode.liquid +++ b/json_lazy_decode.liquid @@ -3,7 +3,7 @@ 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 %} + {% include 'json_lazy_decode' json: product.metafields.global.JAN key: 'three_sixty' %}{% assign three_sixty = jld__yield_1 %} {%- endcomment -%} {%- assign jld__key_quoted = key | append : '"' | prepend : '"' -%} {%- assign jld__value = json | split: jld__key_quoted -%} From e65a625475ddd35ee60cd0adc8f6bcc3265ec4eb Mon Sep 17 00:00:00 2001 From: Joe Refoy Date: Wed, 1 Mar 2017 12:36:12 +1000 Subject: [PATCH 3/3] Update variable name --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 704081a..1f88464 100644 --- a/README.md +++ b/README.md @@ -194,5 +194,5 @@ To overcome this we have developed a very simple lazy parser that only looks for Usage is as follows ```liquid -{% include 'json_lazy_decode' json: product.metafields.global.JAN key: 'three_sixty' %}{% assign three_sixty = jd__yield_1 %} +{% include 'json_lazy_decode' json: product.metafields.global.JAN key: 'three_sixty' %}{% assign three_sixty = jld__yield_1 %} ```