diff options
Diffstat (limited to 'common/object/src/json.rs')
| -rw-r--r-- | common/object/src/json.rs | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/common/object/src/json.rs b/common/object/src/json.rs index c2ee678..0aa4cbd 100644 --- a/common/object/src/json.rs +++ b/common/object/src/json.rs @@ -21,31 +21,19 @@ pub fn object_to_json(reg: &Registry, ob: Object<'_>) -> Value { }; let key = info.name.to_string(); - match ty { - x if x == STR => { - let val = ob.get_typed::<&str>(i).unwrap().to_string().into(); - multi_insert(&mut o, key, val); - } - x if x == OBJECT => { - let val = object_to_json(reg, ob.get_typed::<Object>(i).unwrap()); - multi_insert(&mut o, key, val); - } - x if x == U32 => { - let val = ob.get_typed::<u32>(i).unwrap().into(); - multi_insert(&mut o, key, val); - } - x if x == U64 => { - let val = ob.get_typed::<u64>(i).unwrap().into(); - multi_insert(&mut o, key, val); - } - x if x == F64 => { - let val = ob.get_typed::<f64>(i).unwrap().into(); - multi_insert(&mut o, key, val); - } + let val = match ty { + x if x == STR => ob.get_typed::<&str>(i).unwrap().to_string().into(), + x if x == OBJECT => object_to_json(reg, ob.get_typed::<Object>(i).unwrap()), + x if x == U32 => ob.get_typed::<u32>(i).unwrap().into(), + x if x == U64 => ob.get_typed::<u64>(i).unwrap().into(), + x if x == I64 => ob.get_typed::<i64>(i).unwrap().into(), + x if x == F64 => ob.get_typed::<f64>(i).unwrap().into(), _ => { nonexhaustive = true; + continue; } }; + multi_insert(&mut o, key, val); } if nonexhaustive { o.insert("_nonexhaustive".to_owned(), Value::Bool(true)); |