using MongoDB;
my $content = $db->items->find('something');
my $json;
while($content->next){
push the data into a $json
}
where there is a way
my @variables = $content->all;
foreach (@variables){
push the data into $json
}
Is there any way i can convert directly push the data into json string;
and push the data into Mojolicious
$self->render(json => $json);
Wrote a small Mojo test script for it. Use
to get a list of all pages, not an iterator. Here’s the test:
Output:
Note: I couldn’t use
is_deeplyto test the$jsondata structure because MongoDB adds OIDs. You’ll see them when you dump$json.