diff --git a/ndc_lib/src/stdlib/serde.rs b/ndc_lib/src/stdlib/serde.rs index ad9efb08..60903e27 100644 --- a/ndc_lib/src/stdlib/serde.rs +++ b/ndc_lib/src/stdlib/serde.rs @@ -43,12 +43,15 @@ impl TryFrom for JsonValue { .map(|v| v.clone().try_into()) .collect::, _>>()?, )), - Sequence::Tuple(values) => Ok(Self::Array( - values - .iter() - .map(|v| v.clone().try_into()) - .collect::, _>>()?, - )), + Sequence::Tuple(values) => match values.len() { + 0 => Ok(Self::Null), + _ => Ok(Self::Array( + values + .iter() + .map(|v| v.clone().try_into()) + .collect::, _>>()?, + )), + }, Sequence::Map(values, _) => Ok(Self::Object( values .borrow() diff --git a/tests/programs/605_stdlib_serde/001_json.ndct b/tests/programs/605_stdlib_serde/001_json.ndct index 676144ec..b9453c8e 100644 --- a/tests/programs/605_stdlib_serde/001_json.ndct +++ b/tests/programs/605_stdlib_serde/001_json.ndct @@ -7,6 +7,7 @@ let object = %{ "object": %{ "test": [1,2,3] }, + "set": %{1,2,3}, "list": [1,2,3,4], "tuple": (1,2,3), }; @@ -20,10 +21,11 @@ let result = %{ "object": %{ "test": [1,2,3] }, + "set": %{"1", "2", "3"}, // LMAO this is so lossy "list": [1,2,3,4] }; assert_eq(result, object.json_encode.json_decode); print("ok"); --EXPECT-- -ok \ No newline at end of file +ok