Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: write_file to_json in Dancer app

by GertMT (Hermit)
on Feb 04, 2014 at 16:46 UTC ( [id://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.
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);

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-23 15:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found