How do I get nested data in a database?
I'm using file from json
{
"680546360717606941": {
"business": "user",
"workers": {
"bodyguard": 1
}
}
}
and im trying to do that, but in replit database. how can i get nested data like "business"
edit:
Here's an example -
from replit import db
db["greeting"] = {}
db["greeting"]["nested"] = "hi"
print(db["greeting"]["nested"])
What's supposed to happen is, the value for "greeting" will be another key - "nested", and the value for "nested" will be "hi". That is what you would do in a json, but I don't know how to do that in a replit @Spotandjake
Apparently replit questions do not indent
@triplemilkshake firstly use a code lock by using three ` on either side of your code secondly it depend on the language but often what replit does is return the first object so in py like this db[key] and in js db.get().key or whatever the get call is for replit db I can't remember at the moment as I dont use repldb that much pls mark this as the awnser if it worked hope that helps also try to give more detail in future posts pls.
you can't assign into dicts directly, the client has a bug.
Instead, you have to do it like this:
really dumb, but it is what it is.