Skip to content

Commit 8339d53

Browse files
Update adapter/rest/src/main.rs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Raphael Götz <52959657+raphael-goetz@users.noreply.github.com>
1 parent 0be1a87 commit 8339d53

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

adapter/rest/src/main.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,16 @@ fn pb_value_to_json(v: &Value) -> serde_json::Value {
7272
Some(Kind::NumberValue(n)) => {
7373
if let Some(num) = Number::from_f64(*n) {
7474
J::Number(num)
75+
} else if n.is_nan() {
76+
J::String("NaN".to_string())
77+
} else if n.is_infinite() {
78+
if n.is_sign_positive() {
79+
J::String("Infinity".to_string())
80+
} else {
81+
J::String("-Infinity".to_string())
82+
}
7583
} else {
84+
// Fallback for unexpected cases where from_f64 returns None.
7685
J::Null
7786
}
7887
}

0 commit comments

Comments
 (0)