Skip to content

Commit a7325f4

Browse files
authored
Merge pull request #47 from b41sh/fix-get-by-keypath
fix: fix get by keypath with null value
2 parents 0247ffc + a5dde80 commit a7325f4

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/functions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ pub fn get_by_keypath<'a, I: Iterator<Item = &'a KeyPath<'a>>>(
378378
}
379379
}
380380
// If the key paths is empty, return original value.
381-
if curr_jentry_encoded == 0 {
381+
if curr_val_offset == 0 {
382382
return Some(value.to_vec());
383383
}
384384
curr_jentry

tests/it/functions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,8 @@ fn test_get_by_keypath() {
10541054
("null", " { } ", Some(Value::Null)),
10551055
("null", " { a , b } ", None),
10561056
("true", "{a,b}", None),
1057+
(r#"{"a":{"b":null}}"#, "{a,b}", Some(Value::Null)),
1058+
(r#"[1,"a",null]"#, "{2}", Some(Value::Null)),
10571059
(r#""sdasd""#, "{1}", None),
10581060
("[10,20,30]", "{1}", Some(Value::Number(Number::UInt64(20)))),
10591061
(

0 commit comments

Comments
 (0)