Skip to content

Won't compile with Delphi 10.2 - with hacky solution #14

@rsgrimes

Description

@rsgrimes

The following function fails to compile off master branch with Delphi 10.2:

class function DelphiJSON<T>.Deserialize(data: String; settings: TDJSettings): T;
var
  val: TJSONValue;
begin
  val := nil;
  try
    val := TJSONObject.ParseJSONValue(data, True, True);
    Result := DeserializeJ(val, settings);
  except
    on E: EDJError do
    begin
      val.Free;
      raise E.Clone;
    end;
  end;
  val.Free;
end;

The problem line is the call to ParseJSONValue, which has an extra parameter that Delphi 10.2 does not support. I have hacked it like this:

val := TJSONObject.ParseJSONValue(data, True);  // RSG_HACK - removed extra True parameter

It seems this could be fixed (for Delphi 10.2) by doing a bit of conditional compilation on this part. I took a quick whack at that in my fork (https://github.com/rsgrimes/DelphiJSON) and it now compiles and runs correctly, at least in very limited tests on my part. I also did the same fixes in the tests, and they all run correctly, except for the NonNilableTests.pas module; the issue was not immediately obvious to me, and I'm not sure they apply to me, so I leave that as an exercise for the reader...

I've never contributed to a GitHub project via the forking process in GitHub, so I'm not at all clear how to go about it. If you are interested in pulling in my code, let me know if I can help. The changes are so minor you may choose to do them yourself; it doesn't matter to me - thanks for a great solution for my current use case!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions