I want to generate a json string using Class, I am overwriting a method gistso that it prints what I want:
my $ak = '7111ac873c9dcd5fc335ded47630d050';
my $st = '1523451601875';
my $ifo = 'true';
my $uu = "15778787898988090";
class Stay {
has $.ak is rw = '7111ac873c9dcd5fc335ded47630d050';
has $.uu is rw;
has $.ifo is rw;
has $.st is rw;
method gist() {
return qqww:to「EOF」;
{"ev":"app","ak":"$!ak","uu":"$!uu","ifo":"$!ifo","st":"$!st"}
EOF
}
}
say Stay.new(uu => $uu, ifo => $ifo, st => $st);
but with an error:
===SORRY!=== Error while compiling /Users/ohmycloud/Desktop/stay.pl6
Confused
at /Users/ohmycloud/Desktop/stay.pl6:18
------> {"ev":⏏"app","ak":"$!ak","uu":"$!uu","ifo":"$!i
expecting any of:
colon pair
I want to:
{"ev":"app","ak":"7111ac873c9dcd5fc335ded47630d050","uu":"15778787898988090","ifo":"true","st":"1523451601875"}
Why can't I use a colon pair in qqwwor qq:tostruct?
source
share