I have a model with JSONField:
class SDReport(models.Model):
summary = models.JSONField()
summary
field data example:
{
"1": {
"stm": {
"1": []
},
"non_stm": {
"1": ["3419250", "3205437"]
}
},
"2": {
"stm": {
"1": []
}
}
}
How can select data (expected result ["3419250", "3205437"]
, default value - []
) from path '1' > non_stm > '1'
with ORM?
UPD. This works:
SDReport.objects.annotate(lst=RawSQL("(summary->'1'->'non_stm'->>'1')", ())).first()
But lst
is a string. Is it possible to convert it from string to list in query?