Problem with malformed json using sqlite
Posted: 10.09.2022, 10:43
I have a sqlite table with ID and DATA (Text, to store json data) fields as follows:
ID DATA
1 [1,2,3]
2 ["1","2","3"]
3 [1,2,3, [4,5,6]]
4 [1,2,3,{"AA":4, "BB":5, "CC":6}]
5 [1,2,3
6 [1]
7 {"AA":1}
When I query (using TZQuery) the table with SELECT ID, DATA, json(DATA) FROM TEST
it will raise exception (because record 5 is an invalid JSON) and the the program starts to behalve abnormally because there is memory leak.
I tried the same using TSQlite component, it returns records 1 to 4 and then raise exception. However there is no memory leak.
Is this a bug in the zeoslib component? How to solve this (other then using WHERE clause to filter out the invalid records)?
Attached test.zip (test1 project is using zeoslib and test2 is using TsqliteQuery)
I am using Lazarus 2.2.2 with zeoslib-code-0-r7860-trunk.
ID DATA
1 [1,2,3]
2 ["1","2","3"]
3 [1,2,3, [4,5,6]]
4 [1,2,3,{"AA":4, "BB":5, "CC":6}]
5 [1,2,3
6 [1]
7 {"AA":1}
When I query (using TZQuery) the table with SELECT ID, DATA, json(DATA) FROM TEST
it will raise exception (because record 5 is an invalid JSON) and the the program starts to behalve abnormally because there is memory leak.
I tried the same using TSQlite component, it returns records 1 to 4 and then raise exception. However there is no memory leak.
Is this a bug in the zeoslib component? How to solve this (other then using WHERE clause to filter out the invalid records)?
Attached test.zip (test1 project is using zeoslib and test2 is using TsqliteQuery)
I am using Lazarus 2.2.2 with zeoslib-code-0-r7860-trunk.