MCPcopy
hub / github.com/ampproject/amphtml / tryJsonStringify

Function tryJsonStringify

src/error-reporting.js:117–124  ·  view source on GitHub ↗

* Attempts to stringify a value, falling back to String. * @param {*} value * @return {string}

(value)

Source from the content-addressed store, hash-verified

115 * @return {string}
116 */
117function tryJsonStringify(value) {
118 try {
119 // Cast is fine, because we really don't care here. Just trying.
120 return JSON.stringify(/** @type {!JsonObject} */ (value));
121 } catch (e) {
122 return String(value);
123 }
124}
125
126/**
127 * @param {!Window} win

Callers 1

reportErrorFunction · 0.85

Calls 2

stringifyMethod · 0.80
StringFunction · 0.50

Tested by

no test coverage detected