Function js::jsapi::ToJSONMaybeSafely
[−]
[src]
pub unsafe extern "C" fn ToJSONMaybeSafely(
cx: *mut JSContext,
input: HandleObject,
callback: JSONWriteCallback,
data: *mut c_void
) -> bool
An API akin to JS_Stringify but with the goal of not having observable side-effects when the stringification is performed. This means it does not allow a replacer or a custom space, and has the following constraints on its input:
1) The input must be a plain object or array, not an abitrary value. 2) Every value in the graph reached by the algorithm starting with this object must be one of the following: null, undefined, a string (NOT a string object!), a boolean, a finite number (i.e. no NaN or Infinity or -Infinity), a plain object with no accessor properties, or an Array with no holes.
The actual behavior differs from JS_Stringify only in asserting the above and NOT attempting to get the "toJSON" property from things, since that could clearly have side-effects.