How to convert repl database to json?
h
yoursoulsaver

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?

You are viewing a single comment. View All
OldWizard209

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:

yoursoulsaver

@OldWizard209 I guess that makes sense. How would i upload a already existing json file to the db without having to put each new value in? I tried before and it came out as something unreadable.

OldWizard209

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:
HTML:

JS:

Hope i helped
@yoursoulsaver

OldWizard209

And BTW, are you Alex Cole? just wondering @yoursoulsaver

yoursoulsaver

@OldWizard209 This has helped a lot thanks! Just want to double check is this what you mean?

yoursoulsaver

@OldWizard209 Nope i dont have twitter.

OldWizard209

This has helped a lot thanks! Just want to double check is this what you mean?

Yep exactly what I meant :P

@yoursoulsaver

OldWizard209

@yoursoulsaver

Nope i dont have twitter.

Heheh, sorry, I was just checkin'

yoursoulsaver

@OldWizard209 Its fine. Thanks for your help!