mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 15:39:33 +00:00
Improves jsonencode function
This commit is contained in:
parent
52abb7659a
commit
0b1f12f928
3 changed files with 12 additions and 3 deletions
|
|
@ -2147,9 +2147,17 @@ end
|
|||
|
||||
-- TODO: improve this function
|
||||
function jsonencode(what)
|
||||
tprint(what)
|
||||
what = string.gsub(what, '"', "'")
|
||||
-- everything but all ASCII characters from the space to the tilde
|
||||
what = string.gsub(what, "[^ -~]", " ")
|
||||
-- cleanup line feeds and carriage returns
|
||||
what = string.gsub(what, "\n", " ")
|
||||
what = string.gsub(what, "\r", " ")
|
||||
-- escape all the remaining backslashes
|
||||
what = string.gsub(what, "\\", "\\\\")
|
||||
-- max 1 sequential whitespace
|
||||
what = string.gsub(what, " +"," ")
|
||||
return(what)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue