Here u go
display.setStatusBar( display.HiddenStatusBar ) local json = require ("json") temp\_json = { time = "", milliseconds\_since\_epoch = "", date = "", } function IsInString(theString, theText) print("IsInString()") if (tonumber(string.find(theString, theText)) == nil) then print(" String Not Found."); return false; else -- check the pos if the string to confirm (not nil is not enough) if (tonumber(string.find(theString, theText)) \> 1) then print(" String Found."); return true; else print(" String Not Found."); return false; end end end local function processDownloadedData( event ) print("processDownloadedData()") local retval local dataReceived = false if ( event.isError ) then --Hostname not found? else if (event.response == nil) then -- Error - Unknown Error elseif (event.response == "") then -- Error - Unknown Error elseif (IsInString(event.response, "time") == true) then dataReceived = true --Decode temp\_json = nil; temp\_json = json.decode(event.response); elseif (IsInString(event.response, "error") == true) then --unauthorized if (IsInString(event.response, "unauthorized") == true) then retval = native.showAlert( "Error", "Unnauthorized" , { "OK" }, onGenericAlertBox) end end if temp\_json == false then -- No Data. - Thre was no data returned. else -- now do something with the data print("--json-data----------------------------------------------------------------------------") print("time: " .. tostring(temp\_json.time)); print("offset: " .. tostring(temp\_json.milliseconds\_since\_epoch)); print("date: " .. tostring(temp\_json.date)); print("---------------------------------------------------------------------------------------") end end end -- prepare the network request function getJSONData(url, action, in\_json, callback) print("getJSONData()") local json = require ( "json" ) local headers = {} -- headers["Authorization"] = "Basic " .. mime.b64( "username:password" ) headers["Content-Type"] = "application/json" local params = {} params.headers = headers params.body = json.encode( in\_json ) network.request ( url, action, callback, params ) end -- Call the Data (background Call so it wont pause your app) getJSONData("http://date.jsontest.com", "GET", temp\_json, processDownloadedData)