in reply to Re^2: Detecting type of output from subs
in thread Detecting type of output from subs

I don't know what will be in those functions, but would like to serialize to as correct JSON as possible.

Functions return lists of scalars. It is as correct as possible to transmit a list of scalar. You could use a JSON array for that.

$json->encode( [ f() ] )

The equivalent of

my $s = f(); my @a = f();

is

my $s = $json_decode(...)->[0]; my @a = @{ $json_decode(...) };