Skip to content

Commit f40c3a0

Browse files
committed
feat: handle JavaScript Proxy in array and object deserialization
1 parent bcf847d commit f40c3a0

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/serde/de.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ impl<'de> Deserializer<'de> {
9393
}
9494

9595
fn enter_array(&mut self) -> Result<()> {
96-
let current = self.get_current().clone();
96+
let mut current = self.get_current().clone();
97+
98+
if current.is_proxy() {
99+
current = current.get_proxy_target(true)?;
100+
}
97101

98102
if current.is_array() {
99103
self.guard_circular_reference(&current)?;
@@ -105,7 +109,11 @@ impl<'de> Deserializer<'de> {
105109
}
106110

107111
fn enter_object(&mut self) -> Result<()> {
108-
let current = self.get_current().clone();
112+
let mut current = self.get_current().clone();
113+
114+
if current.is_proxy() {
115+
current = current.get_proxy_target(true)?;
116+
}
109117

110118
if current.is_object() {
111119
let obj = OwnedJsObject::try_from_value(current.clone()).unwrap();

0 commit comments

Comments
 (0)