TJSONObject changes from 2.0 to 2.1

Hi,

I have the following json(part of it) "{"FID":0,"FIDMovimiento":0,"FControl":null,.....}". Using 2.0 on the following code jPair is null and it works ok. On 2.1 jPair is not null and executing the code throws an exception, maybe because jPair.JsonValue.ToString returns 'null'.

jPair := ((jObject as TJSONObject).Get('FControl'));
if Assigned(jPair) then
jResult := (TJSonObject.ParseJSONValue(jPair.JsonValue.ToString) as TJSonObject);

Any hints?

Thanks in advance,

Omar Zelaya

I'm not sure how you expect this to work.
I tested the following code here and it returns the expected null value for FControl:

var
  s: string;
  jo: TJSONObject;
  jpair: TJSONPair;
begin
  s := '{"FID":0,"FIDMovimiento":0,"FControl":null}';
  jo := TJSONObject(TJSONObject.ParseJSONValue(s));
  jPair := jo.Get('FControl');
  console.log(jPair.JsonValue.ToString);
end;

Hi,

This is using 2.0 and as you can see after the code “jPair := ((jObject as TJSONObject).Get('FControl'));” jPair is null so the next statement is evaluated to false and the true part of code of the evaluation is not executed.

This is using 2.1 with the same code and JPair is not null so the code on the evulation is executed throwing exception because jPair.JsonValue.ToString = null.

2.0 and 2.1 behaves diferent with same code.

Thanks in advance,

Omar Zelaya

Hi,
with 2.0 jPair is null with 2.1 is not null.

We did improvements in JSON handling between v2.0 and v2.1
The pair FControl":null exists, so it seems logical & correct that in v2.1 a pair is returned.