I’m pushing my values into the array…
while ( ... ) {
push @array, { label => "label", value => "value" };
}
This appears to be working.
Then…
use JSON::PP ;
print JSON::PP->new->utf8->encode(@array) ;
only generates…
{"value":"value","label":"label"}
but I need…
[{"value":"value","label":"label"}{"value":"value","label":"label"} etc.. ]
(each item in array outputted, not just the first one…)
Any ideas?
Try passing a reference to the array:
Encode is documented to take a scalar, not an array (so you need the reference, which is a scalar).