Hi,
I was using Parse_json and string filter in liquid and shopify dev showed no error and code works fine but shopify deploy says this
Unknown filter ‘string’ used.
Unknown filter ‘parse_json’ used.
how do I resolve this :-/
Hi,
I was using Parse_json and string filter in liquid and shopify dev showed no error and code works fine but shopify deploy says this
Unknown filter ‘string’ used.
Unknown filter ‘parse_json’ used.
how do I resolve this :-/
I’m unaware of a parse_json filter in Liquid, could you share the docs where you’ve found this?
yea… my bad i used it from a stack overflow article…
but weirdly Shopify dev should have given an error as well… same as what shopify deploy does
Sounds like you may be using the CLI, I’d suggest taking a look at the documentation available on Shopify’s site.
I had to come to terms with this… maybe this will help other people new to the platform.
(Note that I’m working on Plus, so be warned.)
I had about 100kb of reusable JSON which is somewhat private and it was being used across multiple projects, I wanted to just dump it in the theme (easy to update later) and parse it server-side in liquid.
Some apps have parse_json and I think this is how it gets into the LLM training data. This is why I thought parse_json was a thing, as I’d seen it in either Mechanic or Datajet.
I don’t know if there is a reason Shopify doesn’t want to provide a json parser. I can vaguely imagine it is to hobble the theming layer to minimise mis-use. I feel the same about the inability to “include” any sort of subroutine that returns an object (you can only render a snippet to a string, basically). It seems like a good way to keep the platform clean.
Of course it’s a scripting/templating engine so it shouldn’t have the ability to fetch. However other templating engines I’ve used like Twig in PHP have the capability to “preprocess” data server-side, and so that’s how my brain thinks.
Anyway, this how to think about it. If the data is available to your frontend on an API, fetch it as JSON in Javascript client-side. The Shopify gods love this as it offloads work to the browser.
If you don’t want your data to be public, it’s not huge and it’s static, you just need to plop it somewhere. You can’t upload it as a file because it’s then public on the CDN, and you can’t parse it anyway afaik. The best solution is a json metadata field on your store - you can access it in the liquid and it’s pre-parsed. You can even put a json schema against it so that store owner doesn’t mess it up.
Obviously the JSON metafield solution can apply to other entities, like you can have a customer metafield that is JSON.
Finally if your need to gather your data from an API and it’s private, it’s an app/extension. I won’t describe this process because I have only done this in a Admin extension.