replace non-UTF chars before json display

master
Garrett Mills 3 years ago
parent c00a05262d
commit 8b8c636cff
  1. 4
      app/assets/dash_v1.js

@ -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, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').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(/&quot;/g, '"'))
json_string = JSON.parse(json_string.replace(/&quot;/g, '"').replace(/\p{C}+/g, '?'))
window.devbug = json_string
}

Loading…
Cancel
Save