You are not logged in.
Pages: 1
Hello everyone,
I have the following understanding problem.
In my database field I store a JSON array:
Field names:
Filter, Type: RawUtf8
TestData, Type: Variant;
Field content:
Filter: Filter = Test
TestData: {"Contents":[{ID: 1, Data:"Test"}, {ID: 2, Data:"Help"}]}}
The line with the required data set is filtered via "Filter = Test" and gets the JSON value.
I hope by then I have been able to explain this clearly. :-)
Well, my problem:
How can I filter within the JSON array after ID = 2 filters?
In the documentary. I read about the function JsonGet (). But unfortunately I can't find an example of how to understand it.
Can someone give me a little example?
Many thanks in advance
Olaf
Offline
Currently, JsonGet() could only retrieve one item in the array list by index, not search within the array...
So you will probably have to retrieve the values in the TSQLRecord, and search by hand using TDocVariant.
Offline
use SQLITE's JSON1 syntax.
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
Yes, I forgot about it, IIRC we compiled SynSQLite3Static.pas including JSON1.
See https://sqlite.org/json1.html
But it will work with standard JSON, not our "extended" JSON standard.
Offline
Oh thank you very much for the helpful hint! That helps me a lot!
Offline
If you use JSON1 remember to call TSQLDataBase.CacheFlush() after edits to keep the ORM cache in sync. I got caught out by that!
Offline
@esmondb, that's a good hint!
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
Pages: 1