Parsing and converting JSON

ParseJSONValue() is a class function of TJSONObject. It does not modify the TJSONObject that it is called on, like you are expecting. It returns a new TJSONValue, which will point to a TJSONObject if the JSON data represents a JSON object. You are ignoring that return value (and thus leaking it, as you need to call Free on it with you are done using it).

You need to change your code to something more like this:

var A: TJSONValue;

A := TJSONObject.ParseJSONValue(Memo1.Text);
if A <> nil then
try
  Memo2.Text := A.ToString;
finally
  A.Free;
end;

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top