Shopify is server side rendered, basically what happens is it will take this liquid code and the liquid engine will turn it into regular html for the browser. What is happening is it appears you are taking this snippet, which is liquid and pasting that into the jsonld validator. You need to actually go a specific page in your browser dev tools and find the <script ld+json> and copy and paste that into the json ld validator.
Once you do this in the browser you will have the regular rendered html. If you take the source code from a liquid file, you will of course get an error because the browser and the validation tool doesn’t understand liquid tags, i.e. {% for %}, {% if %} ect…