Maximum Lua string length

Moderator: leecollings

Post Reply
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Maximum Lua string length

Post 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.
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: Maximum Lua string length

Post 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!
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
georgesattali
Posts: 84
Joined: Saturday 05 March 2016 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

Re: Maximum Lua string length

Post by georgesattali »

don't you miss a parenthesis in the firt line ?

data = assert(io.popen(curl) ) == missing paren ?
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: Maximum Lua string length

Post by Westcott »

Looks like the problem is actually in JSON:decode.
The string must be OK, but print(...) truncates its output?
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest