pub fn object_from_json(&mut self, json: &JSON) -> JSValue {
        if let Some(jobj) = json.as_object() {
            let mut object = JSObject::new();
            for (key, jval) in jobj.iter() {
                let value = self.object_from_json(jval);
                object.set_property(key, Content::Value(value)).unwrap();
            }
            JSValue::Ref(self.alloc(object))
        } else if let Some(jarray) = json.as_array() {
            let storage = (jarray.iter())
                .map(|jval| self.object_from_json(jval))
                .collect();
            let object = JSObject::from_array(storage);
            JSValue::Ref(self.alloc(object))
        } else {
            JSValue::try_from(json).expect("primitive JSON") // not Object/Array, must be primitive
        }
    }
/// Deserializes JSON into objects on the heap
Deserializes JSON into objects on the heap
Deserializes JSON into objects on the heap
pub fn object_from_json(&mut self, json: &JSON) -> JSValue {
        if let Some(jobj) = json.as_object() {
            let mut object = JSObject::new();
            for (key, jval) in jobj.iter() {
                let value = self.object_from_json(jval);
                object.set_property(key, Content::Value(value)).unwrap();
            }
            JSValue::Ref(self.alloc(object))
        } else if let Some(jarray) = json.as_array() {
            let storage = (jarray.iter())
                .map(|jval| self.object_from_json(jval))
                .collect();
            let object = JSObject::from_array(storage);
            JSValue::Ref(self.alloc(object))
        } else {
            JSValue::try_from(json).expect("primitive JSON") // not Object/Array, must be primitive
        }
    }
pub fn object_from_json ( & mut self , json : & JSON ) -> JSValue { if let Some ( jobj ) = json . as_object ( ) { let mut object = JSObject :: new ( ) ; for ( key , jval ) in jobj . iter ( ) { let value = self . object_from_json ( jval ) ; object . set_property ( key , Content :: Value ( value ) ) . unwrap ( ) ; } JSValue :: Ref ( self . alloc ( object ) ) } else if let Some ( jarray ) = json . as_array ( ) { let storage = ( jarray . iter ( ) ) . map ( | jval | self . object_from_json ( jval ) ) . collect ( ) ; let object = JSObject :: from_array ( storage ) ; JSValue :: Ref ( self . alloc ( object ) ) } else { JSValue :: try_from ( json ) . expect ( " " ) // not Object/Array, must be primitive } }
Deserializes JSON into objects on the heap
Deserializes JSON into objects on the heap
&mut self
json
&JSON
&mut self
json
&JSON