Closed Kaiepi closed 1 year ago
unfortunately that's part of JSON::Fast being a drop-in replacement for JSON::Tiny. I want to have something in the future that'd get rid of the scalar container there, but I'm not yet sure what it should look like
Environment: Perl 6.d 2019.03; OS: MacOS Mojave 14.5
Has this issue been solved? @timo
my %data = from-json '[]';
should thow a Error of Type Mismatch; actually got a {}
hash type object; This's unacceptable.
my @data = from-json '[]';
should not wrap another Array outside of the real data; actually got [[]]
。
but
my $data = from-json '[]';
got the right data: []
。
The hash is parsed correctly.
my %data = from-json '{}';
my $data = from-json '{}';
say $data.WHAT, %data.WHAT; # (Hash)(Hash)
FWIW you can deal with this by using :=
instead of =
:
bastille% perl6 -MJSON::Fast -e 'say my @ := from-json "[]"'
[]
the solution for this is to use the immutable
option for from-json, which results in List an Map instead of Array and Hash, and also strips containerization from outside, which allows you to just assign to % and @ sigiled variables. just changing the original way this works was not an option for json::fast's intended use as a drop-in replacement of JSON::Tiny, unfortunately
Pretty self-explanatory: