logica
logica copied to clipboard
Sqlite: StructuredTest returns string instead of json object?
%%logica StructureTest
@Engine("sqlite");
StructureTest(a: {x: 1, y: 2, z: { w: "hello", v: "world"}});
StructureTest(a: {x: 3, y: 4, z: { w: "bonjour", v: "monde"}});
print(StructureTest['a'].values[0])
print(type(StructureTest['a'].values[0]))
print(StructureTest['a'].values[0]['z']['w']) # <===== This is the line in the tutorial that fails
{"x":1,"y":2,"z":{"w":"hello","v":"world"}}
<class 'str'>
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-14-dbaa4016c4ed> in <module>()
2 print(StructureTest['a'].values[0])
3 print(type(StructureTest['a'].values[0]))
----> 4 print(StructureTest['a'].values[0]['z']['w'])
TypeError: string indices must be integers
Yes, that's right. I'm afraid it will have to stay this way for a while. SQLite treats jsons as strings and there is no robust way to differentiate string from object.
We will need to explain it in documentation though.
👍 please close at will.