Sha256: af439b7606870031d37aee69691d41624bdb3b32988e4b02b76b2c655c5bbbd4
Contents?: true
Size: 724 Bytes
Versions: 2
Compression:
Stored size: 724 Bytes
Contents
local http = require("socket.http") local ltn12 = require("ltn12") local M = {} local json = require "json" local parseJson = function( filename ) local file = io.open( filename, "r" ) if file then local contents = file:read( "*a" ) result = json.decode( contents ) io.close( file ) return result else return {} end end M.parseJson = parseJson local parseRemoteJson = function( remoteUrl ) local tempFilename = system.pathForFile( "temp.json", system.TemporaryDirectory ) local tempFile = io.open( tempFilename, "w+b" ) http.request { url = remoteUrl, sink = ltn12.sink.file( tempFile ) } return parseJson( tempFilename ) end M.parseRemoteJson = parseRemoteJson return M
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nakor-0.0.12 | lib/nakor/generators/corona-game-template/scripts/lib/io_ext.lua |
nakor-0.0.10 | lib/nakor/generators/corona-game-template/scripts/lib/io_ext.lua |