MCPcopy Index your code
hub / github.com/angular/angular / toJson

Method toJson

packages/core/src/transfer_state.ts:131–147  ·  view source on GitHub ↗

* Serialize the current state of the store to JSON.

()

Source from the content-addressed store, hash-verified

129 * Serialize the current state of the store to JSON.
130 */
131 toJson(): string {
132 // Call the onSerialize callbacks and put those values into the store.
133 for (const key in this.onSerializeCallbacks) {
134 if (this.onSerializeCallbacks.hasOwnProperty(key)) {
135 try {
136 this.store[key] = this.onSerializeCallbacks[key]();
137 } catch (e) {
138 console.warn('Exception in onSerialize callback: ', e);
139 }
140 }
141 }
142
143 // Escape script tag to avoid break out of <script> tag in serialized output.
144 // Encoding of `<` is the same behaviour as G3 script_builders.
145 // Encoding of `/` prevents crawlers from incorrectly indexing relative URLs in inline JSON.
146 return JSON.stringify(this.store).replace(/</g, '\\u003C').replace(/\//g, '\\u002F');
147 }
148}
149
150export function retrieveTransferredState(

Callers 4

serializeTransferStateFunction · 0.45

Calls 2

warnMethod · 0.65
replaceMethod · 0.45

Tested by

no test coverage detected