Skip to content

Instantly share code, notes, and snippets.

@hapejot
Last active January 21, 2022 12:16
Show Gist options
  • Select an option

  • Save hapejot/59b8a0e16b166693a86b61b4ba5db92e to your computer and use it in GitHub Desktop.

Select an option

Save hapejot/59b8a0e16b166693a86b61b4ba5db92e to your computer and use it in GitHub Desktop.
Write JSON to file
with open("products.json", "r") as read_file:
x = read_file.read()
print(x)
import json
with open("products.json", "r") as read_file:
all_products = json.load(read_file)
print(all_products)
import json
all_products = [{"title": "xxx", "link":"http://xxx/", "sku": "what?", "src": "....."}]
with open("products.json", "w") as write_file:
json.dump(all_products, write_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment