Shopify Python API : How to serialize products list to JSON?
I want to fetch Products list and return as JSON using the Shopify Python API. I tried the .to_json() function
Got the error
'PaginatedCollection' object has no attribute 'to_json'
I tried doing
Object of type Product is not JSON serializable
How can I serialize the Products response to JSON ?
You'll need to loop through the list,convert each to dict (to_dict() function) and append to a list.
products=shopify.Product.find() productsJSON= for product in products: productsJSON.append(product.to_dict())
You can now send productsJSON list as a JSON response.
Try converting it into the dictionary like this:
product=shopify.Product.find(Remote-id of product) product=shopify.Product.find(124583278) product_result = product.to_dict()
Didn't find the answer?
Our community is visited by hundreds of Shopify development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.