Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8014942

JSON.stringify of wrapped objects gets extra quotes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • None
    • core-libs
    • None

      JSON.stringify of objects wrapped with JSAdapter gets an extra wrapper of quotes. The output of the sample program

      function Foo() {
          var that = this;
          return new JSAdapter(Foo.prototype, {}, {
              __call__: function(name) {
                  return that[name].call(that, arguments);
              }
          });
      }
      Foo.prototype.toJSON = function() {
          return '{}';
      }
      var f = new Foo();
      console.log(JSON.stringify(f));

      should be '{}' but is '"{}"'. Whatever the toJSON function returns is wrapped with an extra pair of double-quotes. The extra wrapping is unnecessary, the output of toJSON should be returned unmodified.

            sundar Sundararajan Athijegannathan
            akhil Akhil Arora (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: