Skip to content

Instantly share code, notes, and snippets.

@tianon
Last active January 2, 2016 21:49
Show Gist options
  • Save tianon/8365844 to your computer and use it in GitHub Desktop.
Save tianon/8365844 to your computer and use it in GitHub Desktop.
use Mojo::JSON;
my $json = Mojo::JSON->new;
my $str = '{"some":"json","more":"stuff"}';
my $obj = $json->decode($str);
$obj->{some} = 'changed';
$obj->{new} = 'brand new!';
delete $obj->{more}; # remove that nonsense
$str = $json->encode($obj); # or, $self->render(json => $obj);
print $str; # {"new":"brand new!","some":"changed"}
@jnbek
Copy link

jnbek commented Jan 11, 2014

nice!

@caylorme
Copy link

Thanks for this, tianon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment