MCPcopy Create free account
hub / github.com/ampproject/amphtml / copyJsonObject_

Method copyJsonObject_

extensions/amp-bind/0.1/bind-impl.js:1659–1669  ·  view source on GitHub ↗

* Copies an object containing JSON data and returns it. * Returns null if input object contains invalid JSON (e.g. undefined or * circular references). * @param {?JsonObject|undefined} o * @return {?JsonObject}

(o)

Source from the content-addressed store, hash-verified

1657 * @return {?JsonObject}
1658 */
1659 copyJsonObject_(o) {
1660 if (o === undefined) {
1661 return null;
1662 }
1663 try {
1664 return parseJson(JSON.stringify(o));
1665 } catch (e) {
1666 dev().error(TAG, 'Failed to copy JSON (' + o + ') with error: ' + e);
1667 }
1668 return null;
1669 }
1670
1671 /**
1672 * Print out the current state in the console.

Callers 3

setStateWithObjectMethod · 0.95
getStateMethod · 0.95

Calls 4

parseJsonFunction · 0.90
devFunction · 0.90
stringifyMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected