MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / json_value

Function json_value

crates/openshell-driver-podman/src/driver.rs:1277–1305  ·  view source on GitHub ↗
(value: serde_json::Value)

Source from the content-addressed store, hash-verified

1275 }
1276
1277 fn json_value(value: serde_json::Value) -> prost_types::Value {
1278 match value {
1279 serde_json::Value::Null => prost_types::Value { kind: None },
1280 serde_json::Value::Bool(value) => prost_types::Value {
1281 kind: Some(prost_types::value::Kind::BoolValue(value)),
1282 },
1283 serde_json::Value::Number(value) => prost_types::Value {
1284 kind: value.as_f64().map(prost_types::value::Kind::NumberValue),
1285 },
1286 serde_json::Value::String(value) => prost_types::Value {
1287 kind: Some(prost_types::value::Kind::StringValue(value)),
1288 },
1289 serde_json::Value::Array(values) => prost_types::Value {
1290 kind: Some(prost_types::value::Kind::ListValue(
1291 prost_types::ListValue {
1292 values: values.into_iter().map(json_value).collect(),
1293 },
1294 )),
1295 },
1296 serde_json::Value::Object(values) => prost_types::Value {
1297 kind: Some(prost_types::value::Kind::StructValue(prost_types::Struct {
1298 fields: values
1299 .into_iter()
1300 .map(|(key, value)| (key, json_value(value)))
1301 .collect(),
1302 })),
1303 },
1304 }
1305 }
1306
1307 fn json_struct(value: serde_json::Value) -> prost_types::Struct {
1308 match json_value(value).kind {

Callers 1

json_structFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected