Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: write_file to_json in Dancer app

by GertMT (Hermit)
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.
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? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2021-10-25 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (90 votes). Check out past polls.

    Notices?