0
我正在做一個簡單的網絡請求,以XML格式接收結果。有沒有辦法以JSON格式接收結果(或者這取決於服務器以什麼格式作出迴應)?在Corona中使用JSON而不是XML接收網絡請求
local function networkListener(event)
if (event.isError) then
print("Network error!")
else
print ("RESPONSE: " .. event.response)
end
local saveData = event.response
local path = system.pathForFile("myfile.txt", system.DocumentsDirectory)
local file = io.open(path, "w")
file:write(saveData)
io.close(file)
file = nil
end
network.request("http://www.carsales.com.au/cars/results?area=Stock&vertical=car&sortBy=TopDeal&q=(((Make%3D%5BToyota%5D)%26(Model%3D%5BCamry%5D))%26(Service%3D%5BCarsales%5D)%26(Year%3drange%5b2015..2015%5d))&WT.z_srchsrcx=makemodel/format=json", "GET", networkListener, params)