/// Deserialize an Object and any children from a JSON object
/// It would be best if this was implemented via serde but due to avm and context it can't
/// Undefined fields aren't deserialized
Deserialize an Object and any children from a JSON object
It would be best if this was implemented via serde but due to avm and context it can't
Undefined fields aren't deserialized
Deserialize an Object and any children from a JSON object It would be best if this was implemented via serde but due to avm and context it can ' t Undefined fields aren ' t deserialized
fn deserialize_array<'gc>(
    mut json_obj: json::object::Object,
    activation: &mut Activation<'_, 'gc, '_>,
) -> Value<'gc> {
    let array_constructor = activation.context.avm1.prototypes.array_constructor;
    let len = json_obj
        .get("length")
        .and_then(JsonValue::as_i32)
        .unwrap_or_default();
    if let Ok(Value::Object(obj)) = array_constructor.construct(activation, &[len.into()]) {
        // Remove length and proto meta-properties.
        json_obj.remove("length");
        json_obj.remove("__proto__");
        for entry in json_obj.iter() {
            let value = recursive_deserialize(entry.1.clone(), activation);
            if let Ok(i) = entry.0.parse::<i32>() {
                obj.set_array_element(i as usize, value, activation.context.gc_context);
            } else {
                obj.define_value(
                    activation.context.gc_context,
                    entry.0,
                    value,
                    Attribute::empty(),
                );
            }
        }
        obj.into()
    } else {
        Value::Undefined
    }
}
fn deserialize_array < ' gc > ( mut json_obj : json :: object :: Object , activation : & mut Activation < ' _ , ' gc , ' _ > , ) -> Value < ' gc > { let array_constructor = activation . context . avm1 . prototypes . array_constructor ; let len = json_obj . get ( " " ) . and_then ( JsonValue :: as_i32 ) . unwrap_or_default ( ) ; if let Ok ( Value :: Object ( obj ) ) = array_constructor . construct ( activation , & [ len . into ( ) ] ) { // Remove length and proto meta-properties. json_obj . remove ( " " ) ; json_obj . remove ( " " ) ; for entry in json_obj . iter ( ) { let value = recursive_deserialize ( entry . 1 . clone ( ) , activation ) ; if let Ok ( i ) = entry . 0 . parse :: < i32 > ( ) { obj . set_array_element ( i as usize , value , activation . context . gc_context ) ; } else { obj . define_value ( activation . context . gc_context , entry . 0 , value , Attribute :: empty ( ) , ) ; } } obj . into ( ) } else { Value :: Undefined } }
Deserialize an Object and any children from a JSON object
It would be best if this was implemented via serde but due to avm and context it can't
Undefined fields aren't deserialized
Deserialize an Object and any children from a JSON object It would be best if this was implemented via serde but due to avm and context it can ' t Undefined fields aren ' t deserialized
json_obj
json::object::Object
activation
&mut Activation<'_, 'gc, '_>