replace non-UTF chars before json display
This commit is contained in:
parent
c00a05262d
commit
8b8c636cff
@ -5,7 +5,7 @@ function output(inp) {
|
||||
function syntaxHighlight(json) {
|
||||
console.log(json)
|
||||
json = JSON.stringify(JSON.parse(json.replace(/"/g, '"')), undefined, 4)
|
||||
json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
||||
json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\p{C}+/g, '?'); // replace all non-printable characters
|
||||
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
|
||||
var cls = 'number';
|
||||
if (/^"/.test(match)) {
|
||||
@ -25,6 +25,6 @@ function syntaxHighlight(json) {
|
||||
|
||||
function from_server(json_string){
|
||||
console.log(json_string)
|
||||
json_string = JSON.parse(json_string.replace(/"/g, '"'))
|
||||
json_string = JSON.parse(json_string.replace(/"/g, '"').replace(/\p{C}+/g, '?'))
|
||||
window.devbug = json_string
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user