http://qs321.pair.com?node_id=1073441


in reply to Re: write_file to_json in Dancer app
in thread write_file to_json in Dancer app

aha, yes, thanks. That does work.
The file is updated if I refresh the browser. Well, with not much I'll have to admit but at least the modification time changes.
So, I'm not there with the format but I should be able to work that out.
Thanks!

Replies are listed 'Best First'.
Re^3: write_file to_json in Dancer app
by GertMT (Hermit) on Feb 05, 2014 at 11:06 UTC
    updating the code between the comment lines to the code I mention below makes that the data is been written to a 'json' file. Not very clever code yet as the data gets overwritten every time you run the script but that is a separate issue.
    #-------v this does work --------# my $filename = "testme.json"; my $json = -e $filename ? read_file $filename : '{}'; my $data = from_json $json; $data = \@photos; write_file $filename, to_json($data);