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 %} ``` diff --git a/json_lazy_decode.liquid b/json_lazy_decode.liquid index 7168595..07b4b8a 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 = 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: ',' -%} \ 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: ',' -%}