[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: reading a .json file from disc
- From: Sebastien Lai <237482@...>
- Date: Fri, 15 Jul 2011 21:10:18 +0200
You're using the IO library wrongly:
function file_getdata()
local data_file_path = gre.SCRIPT_ROOT .. "/myfile.json"
local handle = io.open(data_file_path)
local data = handle:read("*all")
handle:close()
return data
end
On Fri, Jul 15, 2011 at 5:00 PM, Dave Collins
<Dave.Collins@mercatustechnologies.com> wrote:
> I'm doing something wrong.
>
> (I am converting an api call into a local file call. It should just read the entire 70K response (in json format) into the var. I parse it out later.)
>
> This hangs my app:
>
> function file_getdata()
> local data_file_path = gre.SCRIPT_ROOT .. "/myfile.json"
> local f = io.open(data_file_path)
> f = io.read("*all")
> f = io.close()
> return f
> end
>
>
>
>
> Dave Collins
> Front-End Engineer
> Mercatus Technologies Inc.
> 60 Adelaide Street East, Suite 700
> Toronto ON M5C 3E4
> T 416 603 3406 x 298
> F 416 603 1790
>
> dave.collins@mercatustechnologies.com
> www.mercatustechnologies.com
>
>