Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re^2: write_file to_json in Dancer app

by GertMT (Friar)
on Feb 04, 2014 at 16:46 UTC ( #1073441=note: print w/replies, xml ) Need Help??

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.

Replies are listed 'Best First'.
Re^3: write_file to_json in Dancer app
by GertMT (Friar) 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);

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1073441]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2021-09-28 05:44 GMT
Find Nodes?
    Voting Booth?

    No recent polls found