I am doing a simple network request where I receive the results in XML format. Is there a way to receive the results in JSON format (or this is up to the server what format to respond)?
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 )
this seems to be only dependent on the server. Some servers such as Google may allow JSON response but many other wont which is pretty stupid.