Software /
code /
prosody
Comparison
util/json.lua @ 5776:bd0ff8ae98a8
Remove all trailing whitespace
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Fri, 09 Aug 2013 17:48:21 +0200 |
parent | 5565:6dd806829226 |
child | 6785:bf1f09a5bcf7 |
comparison
equal
deleted
inserted
replaced
5775:a6c2b8933507 | 5776:bd0ff8ae98a8 |
---|---|
346 }; | 346 }; |
347 | 347 |
348 function json.decode(json) | 348 function json.decode(json) |
349 json = json:gsub("\\.", first_escape) -- get rid of all escapes except \uXXXX, making string parsing much simpler | 349 json = json:gsub("\\.", first_escape) -- get rid of all escapes except \uXXXX, making string parsing much simpler |
350 --:gsub("[\r\n]", "\t"); -- \r\n\t are equivalent, we care about none of them, and none of them can be in strings | 350 --:gsub("[\r\n]", "\t"); -- \r\n\t are equivalent, we care about none of them, and none of them can be in strings |
351 | 351 |
352 -- TODO do encoding verification | 352 -- TODO do encoding verification |
353 | 353 |
354 local val, index = _readvalue(json, 1); | 354 local val, index = _readvalue(json, 1); |
355 if val == nil then return val, index; end | 355 if val == nil then return val, index; end |
356 if json:find("[^ \t\r\n]", index) then return nil, "garbage at eof"; end | 356 if json:find("[^ \t\r\n]", index) then return nil, "garbage at eof"; end |
357 | 357 |
358 return val; | 358 return val; |