[Lazarus] Convert record to JSON?

Bo Berglund bo.berglund at gmail.com
Sun Jul 22 15:43:48 CEST 2018


On Sun, 22 Jul 2018 10:41:23 +0200 (CEST), Michael Van Canneyt via
Lazarus <lazarus at lists.lazarus-ide.org> wrote:

>That is because you cannot pass the array as a var argument. Just remove the
>var, for a dynamic array it is not required anyway.

I did so and the compile error disappeared.
However, now that there are no compile time errors instead I get a
runtime exception inside the call to ObjectToJSONString here:

function TConfigCommHandler.ConfigAsJSON(RC: TEspConfiguration):
string;
{Create a JSON verson of the configuration record}
var
  JS: TJSONStreamer;
begin
  JS := TJSONStreamer.Create(NIL);
  try
    JS.Options := JS.Options + [jsoTStringsAsArray];
    Result := JS.ObjectToJSONString(RC);
  finally
    JS.Free;
  end;
end;

The Exception message is:
' : Unsupported property kind for property: "addr"'

So it is still not supported....


-- 
Bo Berglund
Developer in Sweden



More information about the Lazarus mailing list