#1 2018-04-02 13:28:14

mauriciobs
Member
From: Brazil
Registered: 2016-05-11
Posts: 16

Question about 'RetrieveDocVariantArray' and DynamicArray field

When I use RetrieveListJson (SQLTable, '', [], '*') I get:

{"result":["[{\"ID\":1,\"Ativo\":1,\"Contatos\":\"ï¿°W3siTm9tZSI6IkFsbHlzb24gQm9yZ2VzIiwiVGVsZWZvbmVzIjpbeyJUaXBvIjoiQ09CUkFOQ0EiLCJEREQiOjgzLCJOdW1lcm8iOiI5NzQ3Ni0yNzg5In0seyJUaXBvIjoiRElSRVRPUklBIiwiREREIjo4MywiTnVtZXJvIjoiOTM0MjEtMjEzMyJ9XSwiRW1haWwiOiJhbGx5c29uQHguY29tIn0seyJOb21lIjoiRnJhbmNpc2NvIGRlIEFzc2lzIiwiVGVsZWZvbmVzIjpbXSwiRW1haWwiOiJhc3Npc0B4LmNvbSJ9XQ==\",\"Dados\":\"{\\\"LocalMapa\\\":\\\"\\\"}\"}]\n"],"id":1}

When I use RetrieveDocVariantArray (SQLTable, '', '', [], '*') I get:

{"result":[[{ID:1,Ativo:true,Contatos:null,Dados:{LocalMapa:""}}]],"id":1}

How do I retrieve the 'Contatos' field which is dynamic array using 'RetrieveDocVariantArray'?

Offline

#2 2018-04-02 16:05:09

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,237
Website

Re: Question about 'RetrieveDocVariantArray' and DynamicArray field

Check https://synopse.info/files/html/Synopse … ml#TITL_26
The dynamic arrays are stored as BLOB, and expect the ORM to decode the binary content before process at runtime. There is no direct JSON serialization of dynamic arrays.

If you expect the content to be returned as JSON array, use a variant field and store a TDocVariant in it, or use TObjArray kind of dynamic arrays.

Offline

#3 2018-04-02 17:31:42

mauriciobs
Member
From: Brazil
Registered: 2016-05-11
Posts: 16

Re: Question about 'RetrieveDocVariantArray' and DynamicArray field

Thanks ab, using a variant field and assigning a dynamic array to the field, it worked.

Offline

Board footer

Powered by FluxBB