diff --git a/src/commands/from_ini.rs b/src/commands/from_ini.rs index 7352d4c0db..340ad26e4f 100644 --- a/src/commands/from_ini.rs +++ b/src/commands/from_ini.rs @@ -1,4 +1,4 @@ -use crate::object::{Dictionary, Primitive, SpannedDictBuilder, Value}; +use crate::object::{Primitive, SpannedDictBuilder, Value}; use crate::prelude::*; use std::collections::HashMap; diff --git a/src/commands/from_json.rs b/src/commands/from_json.rs index e81d81e281..36dae4b1b1 100644 --- a/src/commands/from_json.rs +++ b/src/commands/from_json.rs @@ -1,5 +1,5 @@ use crate::object::base::OF64; -use crate::object::{Dictionary, Primitive, SpannedDictBuilder, Value}; +use crate::object::{Primitive, SpannedDictBuilder, Value}; use crate::prelude::*; fn convert_json_value_to_nu_value(v: &serde_hjson::Value, span: impl Into) -> Spanned { diff --git a/src/commands/from_toml.rs b/src/commands/from_toml.rs index ffea6fd5d7..1745548eeb 100644 --- a/src/commands/from_toml.rs +++ b/src/commands/from_toml.rs @@ -1,5 +1,5 @@ use crate::object::base::OF64; -use crate::object::{Dictionary, Primitive, SpannedDictBuilder, Value}; +use crate::object::{Primitive, SpannedDictBuilder, Value}; use crate::prelude::*; fn convert_toml_value_to_nu_value(v: &toml::Value, span: impl Into) -> Spanned { diff --git a/src/commands/from_xml.rs b/src/commands/from_xml.rs index ebfce83e98..db56cb830d 100644 --- a/src/commands/from_xml.rs +++ b/src/commands/from_xml.rs @@ -1,4 +1,4 @@ -use crate::object::{Dictionary, Primitive, SpannedDictBuilder, Value}; +use crate::object::{Primitive, SpannedDictBuilder, Value}; use crate::prelude::*; fn from_node_to_value<'a, 'd>( diff --git a/src/commands/from_yaml.rs b/src/commands/from_yaml.rs index 3c9de7302f..12121037bc 100644 --- a/src/commands/from_yaml.rs +++ b/src/commands/from_yaml.rs @@ -1,5 +1,5 @@ use crate::object::base::OF64; -use crate::object::{Dictionary, Primitive, SpannedDictBuilder, Value}; +use crate::object::{Primitive, SpannedDictBuilder, Value}; use crate::prelude::*; fn convert_yaml_value_to_nu_value(v: &serde_yaml::Value, span: impl Into) -> Spanned { diff --git a/src/commands/to_json.rs b/src/commands/to_json.rs index 0a79ca48c5..335ceee175 100644 --- a/src/commands/to_json.rs +++ b/src/commands/to_json.rs @@ -45,15 +45,17 @@ pub fn to_json(args: CommandArgs) -> Result { let name_span = args.name_span; Ok(out .values - .map(move |a| match serde_json::to_string(&a) { - Ok(x) => { - ReturnSuccess::value(Value::Primitive(Primitive::String(x)).spanned(name_span)) - } - Err(_) => Err(ShellError::maybe_labeled_error( - "Can not convert to JSON string", - "can not convert piped data to JSON string", - name_span, - )), - }) + .map( + move |a| match serde_json::to_string(&value_to_json_value(&a)) { + Ok(x) => { + ReturnSuccess::value(Value::Primitive(Primitive::String(x)).spanned(name_span)) + } + Err(_) => Err(ShellError::maybe_labeled_error( + "Can not convert to JSON string", + "can not convert piped data to JSON string", + name_span, + )), + }, + ) .to_output_stream()) } diff --git a/src/object/dict.rs b/src/object/dict.rs index e0844dda57..16c7d32818 100644 --- a/src/object/dict.rs +++ b/src/object/dict.rs @@ -72,20 +72,6 @@ impl PartialEq for Dictionary { } impl Dictionary { - crate fn add(&mut self, name: impl Into, value: impl Into>) { - self.entries.insert(name.into(), value.into()); - } - - crate fn copy_dict(&self) -> Dictionary { - let mut out = Dictionary::default(); - - for (key, value) in self.entries.iter() { - out.add(key.clone(), value.clone()); - } - - out - } - pub fn get_data(&'a self, desc: &String) -> MaybeOwned<'a, Value> { match self.entries.get(desc) { Some(v) => MaybeOwned::Borrowed(v), diff --git a/src/object/files.rs b/src/object/files.rs index 210ff5405e..0e031b1544 100644 --- a/src/object/files.rs +++ b/src/object/files.rs @@ -1,5 +1,5 @@ use crate::errors::ShellError; -use crate::object::{Dictionary, SpannedDictBuilder, Value}; +use crate::object::{SpannedDictBuilder, Value}; use crate::prelude::*; #[derive(Debug)] diff --git a/src/parser/parse/span.rs b/src/parser/parse/span.rs index 3886f40e18..7b98a00a29 100644 --- a/src/parser/parse/span.rs +++ b/src/parser/parse/span.rs @@ -1,7 +1,7 @@ use crate::Text; use derive_new::new; use getset::Getters; -use serde::{Serialize, Serializer}; +use serde::Serialize; use serde_derive::Deserialize; #[derive( diff --git a/src/prelude.rs b/src/prelude.rs index 67454939c6..7316efada3 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -40,7 +40,7 @@ crate use crate::context::Context; crate use crate::env::host::handle_unexpected; crate use crate::env::{Environment, Host}; crate use crate::errors::ShellError; -crate use crate::object::types::{ExtractType, Type}; +crate use crate::object::types::ExtractType; crate use crate::object::{Primitive, Value}; crate use crate::parser::{Span, Spanned, SpannedItem}; crate use crate::stream::{InputStream, OutputStream};