diff --git a/crates/nu-command/src/dataframe/values/nu_dataframe/custom_value.rs b/crates/nu-command/src/dataframe/values/nu_dataframe/custom_value.rs index 8276e6fe3e..e657756a5b 100644 --- a/crates/nu-command/src/dataframe/values/nu_dataframe/custom_value.rs +++ b/crates/nu-command/src/dataframe/values/nu_dataframe/custom_value.rs @@ -33,10 +33,6 @@ impl CustomValue for NuDataFrame { Ok(Value::List { vals, span }) } - fn to_json(&self) -> nu_json::Value { - nu_json::Value::Null - } - fn as_any(&self) -> &dyn std::any::Any { self } diff --git a/crates/nu-command/src/dataframe/values/nu_expression/custom_value.rs b/crates/nu-command/src/dataframe/values/nu_expression/custom_value.rs index 528b861303..665a4e15f0 100644 --- a/crates/nu-command/src/dataframe/values/nu_expression/custom_value.rs +++ b/crates/nu-command/src/dataframe/values/nu_expression/custom_value.rs @@ -34,10 +34,6 @@ impl CustomValue for NuExpression { Ok(self.to_value(span)) } - fn to_json(&self) -> nu_json::Value { - nu_json::Value::Null - } - fn as_any(&self) -> &dyn std::any::Any { self } diff --git a/crates/nu-command/src/dataframe/values/nu_lazyframe/custom_value.rs b/crates/nu-command/src/dataframe/values/nu_lazyframe/custom_value.rs index c33dcd06b2..5a64534701 100644 --- a/crates/nu-command/src/dataframe/values/nu_lazyframe/custom_value.rs +++ b/crates/nu-command/src/dataframe/values/nu_lazyframe/custom_value.rs @@ -47,10 +47,6 @@ impl CustomValue for NuLazyFrame { Ok(Value::Record { cols, vals, span }) } - fn to_json(&self) -> nu_json::Value { - nu_json::Value::Null - } - fn as_any(&self) -> &dyn std::any::Any { self } diff --git a/crates/nu-command/src/dataframe/values/nu_lazygroupby/custom_value.rs b/crates/nu-command/src/dataframe/values/nu_lazygroupby/custom_value.rs index 9123cb8ee4..3a52d872dc 100644 --- a/crates/nu-command/src/dataframe/values/nu_lazygroupby/custom_value.rs +++ b/crates/nu-command/src/dataframe/values/nu_lazygroupby/custom_value.rs @@ -38,10 +38,6 @@ impl CustomValue for NuLazyGroupBy { Ok(Value::Record { cols, vals, span }) } - fn to_json(&self) -> nu_json::Value { - nu_json::Value::Null - } - fn as_any(&self) -> &dyn std::any::Any { self } diff --git a/crates/nu-command/src/dataframe/values/nu_when/custom_value.rs b/crates/nu-command/src/dataframe/values/nu_when/custom_value.rs index 81980a12e0..02238b3292 100644 --- a/crates/nu-command/src/dataframe/values/nu_when/custom_value.rs +++ b/crates/nu-command/src/dataframe/values/nu_when/custom_value.rs @@ -34,10 +34,6 @@ impl CustomValue for NuWhen { Ok(value) } - fn to_json(&self) -> nu_json::Value { - nu_json::Value::Null - } - fn as_any(&self) -> &dyn std::any::Any { self } diff --git a/crates/nu-command/src/formats/to/json.rs b/crates/nu-command/src/formats/to/json.rs index 72cbb8519e..ffe15f256b 100644 --- a/crates/nu-command/src/formats/to/json.rs +++ b/crates/nu-command/src/formats/to/json.rs @@ -142,7 +142,10 @@ pub fn value_to_json_value(v: &Value) -> Result { let collected = val.collect()?; value_to_json_value(&collected)? } - Value::CustomValue { val, .. } => val.to_json(), + Value::CustomValue { val, span } => { + let collected = val.to_base_value(*span)?; + value_to_json_value(&collected)? + } }) } diff --git a/crates/nu-protocol/src/value/custom_value.rs b/crates/nu-protocol/src/value/custom_value.rs index 531a9c7cf7..0822853f28 100644 --- a/crates/nu-protocol/src/value/custom_value.rs +++ b/crates/nu-protocol/src/value/custom_value.rs @@ -17,11 +17,6 @@ pub trait CustomValue: fmt::Debug + Send + Sync { // That already exist in nushell fn to_base_value(&self, span: Span) -> Result; - // Json representation of custom value - fn to_json(&self) -> nu_json::Value { - nu_json::Value::Null - } - // Any representation used to downcast object to its original type fn as_any(&self) -> &dyn std::any::Any;