How to convert repl database to json?
Hi there, im fiddling around with the repl database and in my code i wanted to get a database value and convert it to a json file for my code to read. After many failed attempts i have almost given up. How should i go about doing this?
Replit saves database values as JSON. So let's say you save two values into the databse,
Name: "John, Age: 21. In the database, the values will be in this format:
However, if you want to store an object into the db, you can do that, simply by assigning the object as the value to the key. So added on to the existing db:
are you using python? if so, i would recommend use the json module, read the contents of the file, and upload the content to the database. Although, you will need to assign the entire content to a key, it will work just fine.
If you are using JS, the simplest way is to pass in script tags of your json file and your js script in a html file, and in the js file use this code:
Hope i helped