MCPcopy Create free account
hub / github.com/aeroxy/chrome-devtools-cli / parse_json_value

Function parse_json_value

src/lib.rs:455–481  ·  view source on GitHub ↗
(v: &str)

Source from the content-addressed store, hash-verified

453}
454
455fn parse_json_value(v: &str) -> serde_json::Value {
456 if v.eq_ignore_ascii_case("true") {
457 serde_json::Value::Bool(true)
458 } else if v.eq_ignore_ascii_case("false") {
459 serde_json::Value::Bool(false)
460 } else if v.eq_ignore_ascii_case("null") {
461 serde_json::Value::Null
462 } else if let Ok(n) = v.parse::<i64>() {
463 if n.to_string() == v {
464 serde_json::Value::Number(n.into())
465 } else {
466 serde_json::Value::String(v.to_string())
467 }
468 } else if let Ok(f) = v.parse::<f64>() {
469 if let Some(num) = serde_json::Number::from_f64(f) {
470 if num.to_string() == v {
471 serde_json::Value::Number(num)
472 } else {
473 serde_json::Value::String(v.to_string())
474 }
475 } else {
476 serde_json::Value::String(v.to_string())
477 }
478 } else {
479 serde_json::Value::String(v.to_string())
480 }
481}
482
483/// True for strings that look like an intentional `key=value` key (e.g. `limit`,
484/// `safeSearch`, `second_arg`) rather than a positional value that merely

Callers 2

parse_kvFunction · 0.85
parse_argsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected