[fpc-pascal] JSONToObject with array of any type

Michael Van Canneyt michael at freepascal.org
Sat Oct 1 16:29:48 CEST 2022



On Sat, 1 Oct 2022, Hairy Pixels via fpc-pascal wrote:

> I have some JSON with a “arguments” value which can be an array of JSON type. When it’s received and parsed with TJSONDeStreamer.JSONToObject how can I represent this “any” type? I tried using TJSONArray but it always returns an empty array.
>
> The JSON is parse:
>
> {
>    "command": "do_stuff",
>    "arguments": ["path", 1, 80]
> }
>
> The object to stream to:
>
>  TExecuteCommandParams = class
>    private
>      fCommand: String;
>      fArguments: TJSONArray;
>    published
>      property command: String read fCommand write fCommand;
>      property arguments: TJSONArray read fArguments write fArguments;
>  end;

The standard streamer does not allow this (yet). It is on my todo list to
improve it.

Michael.


More information about the fpc-pascal mailing list