1

If I have a TRESTResponseDataSetAdapter with RootElement = 'testdata' and provide it with the following JSON, it adds a row to the connected dataset.

   RESTResponseDataSetAdapter1.ResponseJSON := TRESTResponseJSON.Create(
      Form1,
      TJSONObject.ParseJSONValue('{"testdata":[]}'),
      true
   );

If I provide some data in the array, I get the expected rows in the dataset, but if the array is empty I get a row with what appears to be all null values.

It seems that the only way to get an empty dataset is to provide something invalid, like {"testdata":[,]} for example. That gives me an empty dataset without generating any errors.

Is this the expected behaviour? If not, what could be the issue here? I've tried changing the TypesMode but I get the same result no matter which setting it is.

The dataset I'm using is a TdxMemData from DevExpress. I recently upgraded from Delphi 10.2 to Delphi 10.4. Things were working fine on 10.2 (i.e. if the JSON array was empty, the dataset would also be empty), so it seems that something has changed in 10.3 or 10.4.

Magnus
  • 17,157
  • 19
  • 104
  • 189
  • I notice there is a new property (with zero description) that is set to 1 by default: `SampleObjects`. Try setting to 0 as a shot in the dark. The comments in the source says it samples this many records to determine structure - it might be pulling an empty record. – Brian Mar 18 '21 at 20:23
  • @Brian Unfortunately it didn't make any difference if I set it to `0`. I tried setting it to both `0` and `1` with all three settings for `TypesMode` as well, same result every time. – Magnus Mar 18 '21 at 20:45
  • @MagnusW have you get any success on that behavior. I am at the same situation right now. – fisi-pjm Aug 11 '21 at 14:46
  • @fisi-pjm No, unfortunately not. I think it's a bug, and I ended up ditching TRESTResponseDataSetAdapter and using my own JSON parsing routines instead. I wasted a lot of time on it, and I think if this is the level of bugs that can slip through whatever unit testing Embarcadero has in place whenever they release an update, it's better to avoid becoming dependent on their components in the first place. – Magnus Aug 11 '21 at 20:25
  • @MagnusW I have created a Issue Report on Embarcadero. If you like you can upvote that ticket to help Embarcadero getting better and better ;-) https://quality.embarcadero.com/browse/RSP-34548 – fisi-pjm Aug 12 '21 at 06:02

0 Answers0