Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-12336

javascript json serilize error

    XMLWordPrintable

    Details

    • Type: Problem report
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't fix
    • Affects Version/s: 3.0.9
    • Fix Version/s: None
    • Component/s: Frontend (F)
    • Labels:
    • Environment:
      macOS Sierra Chrome ?? 59.0.3071.115?????? ?64 ??
    • Sprint:
      Sprint 13, Sprint 14

      Description

      open zabbix monitor page then type

      JSON.stringify({123: [124,"test"]})

      in chrome console.
      the normal result should be

      "{"123":[124,"test"]}"

      but my chrome show

      "{"123":"[124, \"test\"]"}"

      i change four places in js/vendors/prototype.js fix this for now.

       578   function inspect(useDoubleQuotes) {
       579     var escapedString = this.replace(/[\x00-\x1f\\]/g, function(character) {
       580       if (character in String.specialChar) {
       581         return String.specialChar[character];
       582       }
       583       return '\\u00' + character.charCodeAt().toPaddedString(2, 16);
       584     });
       585     if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"'; //=> if (useDoubleQuotes) return escapedString.replace(/"/g, '\\"');
       586     return "'" + escapedString.replace(/'/g, '\\\'') + "'"; //=>  return escapedString.replace(/'/g, '\\\'');
       587   }
      
      1053   function toJSON() {
      1054     var results = [];
      1055     this.each(function(object) {
      1056       var value = Object.toJSON(object);
      1057       if (!Object.isUndefined(value)) results.push(value);
      1058     });
      1059     return '[' + results.join(', ') + ']';  // => return results;
      1060   }
      
      1257   function toJSON() {
      1258       return isFinite(this) ? this.toString() : 'null'; //=> return this;
      1259   }
      
      1053   function toJSON() {
      1054     var results = [];
      1055     this.each(function(object) {
      1056       var value = Object.toJSON(object);
      1057       if (!Object.isUndefined(value)) results.push(value);
      1058     });
      1059     return '[' + results.join(', ') + ']';  // => return results;
      1060   }
      

      Am I right?

      I use 3.0.9 and I don't check other version for this. sorry for that.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            quxuan 屈轩
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: