File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -166,7 +166,15 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
166166 where
167167 V : Visitor < ' de > ,
168168 {
169- let current = self . get_current ( ) ;
169+ let raw_current = self . get_current ( ) ;
170+ let current_proxy;
171+
172+ let current = if raw_current. is_proxy ( ) {
173+ current_proxy = Some ( raw_current. get_proxy_target ( true ) ?) ;
174+ current_proxy. as_ref ( ) . unwrap ( )
175+ } else {
176+ raw_current
177+ } ;
170178
171179 match current. tag ( ) {
172180 JsTag :: Undefined => visitor. visit_unit ( ) ,
Original file line number Diff line number Diff line change @@ -457,3 +457,20 @@ enum SimpleEnum {
457457 D ( bool , u32 ) ,
458458 Foo ( Bar ) ,
459459}
460+
461+ #[ test]
462+ fn serde_de_proxy ( ) {
463+ let script = r#"
464+ const obj = [123, 456]
465+ new Proxy(obj, {
466+ get(target, prop) {
467+ return target[prop];
468+ }
469+ })
470+ "# ;
471+ let context = Context :: builder ( ) . build ( ) . unwrap ( ) ;
472+ let proxy = context. eval ( script, false ) . unwrap ( ) ;
473+ let result: serde_json:: Value = from_js ( unsafe { context. context_raw ( ) } , & proxy) . unwrap ( ) ;
474+ let json_str = serde_json:: to_string ( & result) . unwrap ( ) ;
475+ assert_eq ! ( json_str, r#"[123,456]"# ) ;
476+ }
You can’t perform that action at this time.
0 commit comments