#1 2024-12-19 13:19:55

anouri
Member
Registered: 2024-02-11
Posts: 51

Unnecessary nested array in json

Hi,
I tried both :
1-

  dbStmt := dbConn.NewStatementPrepared(sql, True);
  dbStmt.ExecutePreparedAndFetchAllAsJson(True, LJson);

2-

  LJson := dbConn.Execute(sql,[]).FetchAllAsJson(True);

Both create json with unnecessary array and I can't find option to disable.
{"result": [[{"code": "01","descr": "a"}]]}

Last edited by anouri (2024-12-19 13:21:00)

Offline

#2 2024-12-19 14:12:07

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

Re: Unnecessary nested array in json

A lot to guess, here.

I guess that you are using interface-based services.
I guess that you have a method with a single result/out parameter.

The output is as documented by default: a" result" field with an array of output values, one per parameter.
Since you have a single result parameter, you have an array of an array.
All as expected.
https://synopse.info/files/html/Synopse … #TITLE_470

You can set ResultAsJsonObjectWithoutResult := true at the TServiceFactory level to change the output format.

Offline

#3 Today 07:47:12

anouri
Member
Registered: 2024-02-11
Posts: 51

Re: Unnecessary nested array in json

Yes it is interface-based service.
Solved.
Thank you so much.

Last edited by anouri (Today 08:08:50)

Offline

Board footer

Powered by FluxBB