[Lazarus] Convert record to JSON?

Michael Van Canneyt michael at freepascal.org
Sun Jul 22 07:52:40 CEST 2018



On Sun, 22 Jul 2018, Bo Berglund via Lazarus wrote:

> On Sun, 22 Jul 2018 00:22:58 +0200, Bo Berglund via Lazarus
> <lazarus at lists.lazarus-ide.org> wrote:
>
>> Can the JSON handlers deal with the array type TIpAddress?
>
> Well, it trurns out that this fails earlier on when compiling...
> So I have:
>
> type
>  TIpAddress = array[0..3] of byte;
>
>  {$M+}
>  TEspConfiguration = Class(TObject)
>  private
>    Fchecksum: word;
>    Fssid: AnsiString;
>    ...
>    Faddr: TIpAddress;  //<==
>    ...
>  published
>    property checksum: word read Fchecksum write Fchecksum;
>    property ssid: AnsiString read Fssid write Fssid ;
>    ...
>    property addr: TIpAddress read Faddr write Faddr; // <==
>    ...
>  end
>
> When compiling I get the following error on the "property addr" line:
>
> wificommhandler.pas(97,33) Error: This kind of property cannot be
> published

Only dynamic arrays can be published.

>
> If I replace the type declaration TIpAddress with array[0..3] of byte
> it just adds another error message...
>
> Can published properties only be simple variable types not including
> arrays?
> Seems odd since an AnsiString, which is accepted, is just an array of
> AnsiChar.

Yes, but it is a dynamic array.

Michael.


More information about the Lazarus mailing list