1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#!/usr/bin/env raku
use Test;
use JSON::Class;
use JSON::OptIn;
use JSON::Name;
use JSON::Fast;
class TestOptIn does JSON::Class[:opt-in] {
has Str $.secret = "secret";
has Str $.public is json = "public";
has Str $.named is json-name('Named') = "named";
}
my $obj = TestOptIn.new;
my $json = $obj.to-json;
my %data = from-json($json);
is %data<public>, 'public', 'got opted-in attribute';
is %data<Named>, 'named', 'got implicit attribute';
ok not %data<secret>:exists, "Don't have the not opted in attribute";
done-testing;
# vim: ft=raku
|