Page 1 of 1

Maximum Lua string length

Posted: Thursday 07 April 2016 19:50
by Westcott
What is the maximum Lua string length?
I ask because the string I'm getting from a curl call seems to be truncated.

Code: Select all

data = assert(io.popen(curl)
alldata = data:read('*all')
data:close()
print(alldata)
decodeddata = JSON:decode(alldata)
Yes, I could read it line-by-line, but in this case 'alldata' is a Json result.
It's then to be decoded by JSON.lua, but fails because of the truncation.

Re: Maximum Lua string length

Posted: Thursday 07 April 2016 20:15
by woody4165
Strange thing is that the waze script return a bigger number of data (I saved both), 27Kb waze vs 22Kb GMaps

This is the part extracted from the waze script:

Code: Select all

        local waze=assert(io.popen('curl "https://www.waze.com/row-RoutingManager/routingRequest?from=x%3A'..departx..'+y%3A'..departy..'&to=x%3A'..arrivex..'+y%3A'..arrivey..'&returnJSON=true&timeout=6000&nPaths=1&options=AVOID_TRAILS%3At%2CALLOW_UTURNS"'))
        local trajet = waze:read('*all')
        waze:close()

        local jsonTrajet = json:decode(trajet)

And it works!

Re: Maximum Lua string length

Posted: Thursday 07 April 2016 20:17
by georgesattali
don't you miss a parenthesis in the firt line ?

data = assert(io.popen(curl) ) == missing paren ?

Re: Maximum Lua string length

Posted: Friday 08 April 2016 10:41
by Westcott
Looks like the problem is actually in JSON:decode.
The string must be OK, but print(...) truncates its output?