Software /
code /
prosody
Comparison
util/json.lua @ 6054:7a5ddbaf758d
Merge 0.9->0.10
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 02 Apr 2014 17:41:38 +0100 |
parent | 5776:bd0ff8ae98a8 |
child | 6785:bf1f09a5bcf7 |
comparison
equal
deleted
inserted
replaced
6053:2f93a04564b2 | 6054:7a5ddbaf758d |
---|---|
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; |