File: 050-json-name.rakutest

package info (click to toggle)
raku-json-unmarshal 0.15-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 160 kB
  • sloc: makefile: 4
file content (26 lines) | stat: -rw-r--r-- 472 bytes parent folder | download
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