Skip to content

Instantly share code, notes, and snippets.

@Altreus
Last active March 9, 2020 13:04
Show Gist options
  • Save Altreus/6aa5a48ea3e42cad0225dda6469bee87 to your computer and use it in GitHub Desktop.
Save Altreus/6aa5a48ea3e42cad0225dda6469bee87 to your computer and use it in GitHub Desktop.
raku json round-trip
> my @arr = 1,2,3; my $json = (to-json @arr); my @arr2 = from-json $json; @arr2.say
[[1 2 3]]
> class FromJson { has @.arr; has $.foo }
(FromJson)
> my $item = from-json '{ "arr": [1,2,3], "foo": "a value"}';
{arr => [1 2 3], foo => a value}
> FromJson.new(|$item)
FromJson.new(arr => [[1, 2, 3],], foo => "a value")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment