online/src/js/editors.js
function toText (obj) {
  if (obj instanceof Error) {
    return {
      isJSON: false,
      text: obj.message + "\n\n" + obj.stack
    };
  }
  else {
    try {
      return {
        isJSON: true,
        text: JSON.stringify(obj, null, 2)
      };
    }
    catch (e) {
      return {
        isJSON: false,
        text: "This API is valid, but it cannot be shown because it contains circular references\n\n" + e.stack
      };
    }
  }
}
function toText (obj) {
  if (obj instanceof Error) {
    return {
      isJSON: false,
      text: obj.message + "\n\n" + obj.stack
    };
  }
  else {
    try {
      return {
        isJSON: true,
        text: JSON.stringify(obj, null, 2)
      };
    }
    catch (e) {
      return {
        isJSON: false,
        text: "This API is valid, but it cannot be shown because it contains circular references\n\n" + e.stack
      };
    }
  }
}
function toText ( obj ) { if ( obj instanceof Error ) { return { isJSON : false , text : obj . message + "\n\n" + obj . stack } ; } else { try { return { isJSON : true , text : JSON . stringify ( obj , null , 2 ) } ; } catch ( e ) { return { isJSON : false , text : "This API is valid, but it cannot be shown because it contains circular references\n\n" + e . stack } ; } } }
Converts the given object to text.
If possible, it is converted to JSON; otherwise, plain text.

@param {object} obj
@returns {object}
Converts the given object to text . If possible it is converted to JSON ; otherwise plain text .