How to return json root with liquid?

How to return json root with liquid?

Johnwe
Visitor
3 0 0

How to return json root with liquid? Assuming the root is unnamed how can it be rendered?

{

    "name": "John",

     "title": "Developer"

     "info": {1, 2, 3}

}

Replies 5 (5)

PaulNewton
Shopify Partner
7192 635 1494

Hi @Johnwe 👋 define what you mean by "root" and in context of which system.

This is the shopify-scripts forum for a now depreated feature that works in the checkout, not for javascript or liquid related issues.

 

Alot of shopify interfaces do not allow raw access to underlying contexts.

Contact [email protected] for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


Johnwe
Visitor
3 0 0

Hi Paul

 

Please let me know if there's a better place to post liquid questions.

 

I want the top level of the hierarchy. I'm assuming that I could get the

full json and then target the top level object by index number? Or is there

a way just to get the top level items?

 

In this example I want just everything from "id" to "updated_at". I don't

want any of the sub levels inside "answers".

 

{

"id": "6002730376226774524",

"form_id": "241027993450154",

"ip": "74.113.132.26",

"created_at": "2024-08-23 21:43:57",

"status": "ACTIVE",

"new": "1",

"flag": "0",

"notes": "",

"updated_at": null,

"answers": {

"First Answer": {

"name": "administrativeContact",

"order": "22",

"sublabels": "{ \"field_1\":\"First Name\",\"field_3\":\"Last

Name\",\"field_4\":\"Phone\",\"field_5\":\"Title\"}",

"text": "Administrative Contact",

"type": "control_mixed",

"answer": {

"field_1": "Jack",

"field_3": "Waters",

"field_5": "Director",

"field_4": "111-111-1111"

},

"prettyFormat": "

 

First Name:

Jack

Last Name:

Waters

Title:

Director

Phone:

111-111-1111

"

}

}

}

 

Thx!

PaulNewton
Shopify Partner
7192 635 1494

What "hierarchy", where do "answers" come from,  etc Is this chatgpt generated?

Other people are not mind readers shopify is big system provide context.

There is no defined "control_mixed" type in shopify

"administrativeContact" is normally something found in DNS records which shopify does not have api access for,  or B2B systems

 

Do you mean the shop object in liquid for a theme as "root"?

https://shopify.dev/docs/api/liquid/objects/shop

 

Explain the goal and specifics, what is the context of the code samples: 

https://xyproblem.info/ 

https://meta.stackexchange.com/questions/18584/how-to-ask-a-smart-question 

 

Good Luck.

 

Contact [email protected] for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


Johnwe
Visitor
3 0 0

The data source isn't Shopify. I'm using Liquid in a non-Shopify context (Azure), which supports Liquid. The source json comes from jotform. 

 

When i said "root" i was referring to the json data itself, not any external system. I meant the top level of the json structure i shared. 

 

I assume Liquid syntax doesn't care where the data comes from. 

 

Thx.

 

PaulNewton
Shopify Partner
7192 635 1494

Shopify != general liquid support.

Shopify is the the ecommerce platform.

Liquid is just a templating language they made for their themes that they made open source that other platforms use too.

https://github.com/Shopify/liquid

 

Unless this in the context of an actual shopify theme or app you've come to the place that built a bolt designer for how bolts are made for yet other bolt sellers instead of the car dealership.

For third party systems, or third party libraries, implementing a programming language as a custom DSL see that third parties docs, forums or support.

 

Contact [email protected] for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org