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
|
#!raku
use v6;
use lib 'lib';
use Test;
use JSON::Unmarshal;
use JSON::Name;
plan 2;
class TestClass {
has $.nice-name is rw is json-name('666.evil.name');
}
my $json = '{ "666.evil.name" : "some value we want" }';
my $obj;
lives-ok { $obj = unmarshal($json, TestClass) }, "Unmarshal object with a json-name attribute";
is $obj.nice-name,"some value we want", "and we got the key back with the json name";
done-testing;
# vim: expandtab shiftwidth=4 ft=raku
|