Created
November 12, 2014 11:08
-
-
Save tobyink/53b1ce74829a278b529e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v5.14; | |
use JSON::PP; | |
use JSON::Hyper; | |
use Data::Dumper; | |
use Devel::Confess; | |
# Construct a URI which has some JSON data. I'm using a | |
# data: URI because I'm too lazy to upload some JSON | |
# somewhere, but any URI that returns JSON should be OK. | |
# | |
my $uri = do { | |
require URI::data; | |
my $tmp = URI::->new('data:'); | |
$tmp->media_type('application/json'); | |
$tmp->data('{ "answer": 42 }'); | |
$tmp; | |
}; | |
my $stuff = JSON::PP::->new->decode(<<"JSON"); | |
{ | |
"foo": { "\$ref": "$uri" }, | |
"bar": [] | |
} | |
JSON | |
print Dumper($stuff); | |
JSON::Hyper::->new->process_includes($stuff, 'http://example.com/', !!1); | |
print Dumper($stuff); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment