File: 070-opt-in.t

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