Closed Nekmo closed 7 years ago
@Nekmo you could use EmbeddedField
for that with special model that keeps structure (and keys you are talking about).
Unless you want to have this dynamic, as in example?
I'm closing this issue, since I find this very non-JSON like (I tried "dict approach" few times - it is usually too hard to expand in future, plus you'd loose ability to validate it properly with json schema).
I'm wondering how to define a model for a string dictionary like below. The keys are dynamic, and I need validation to check value is JSON serializable type.
{
"environment": {
"HOME": "/home/user",
"MY_VAR": "1"
}
}
+1 - I have some dynamic data. What's the right way to handle that?
FWIW, 'jsonobject' has a DictProperty which accomplishes this. Unfortunately that module doesn't work for my purposes due to other reasons.
Similar to ListField, but the keys are unique strings. This ensures that it is a primary key and easy access. For Example:
It will be serialized as: