nushell/src/commands/to_json.rs

10 lines
302 B
Rust
Raw Normal View History

2019-05-28 06:00:00 +02:00
use crate::object::{Primitive, Value};
use crate::prelude::*;
pub fn to_json(args: CommandArgs) -> Result<OutputStream, ShellError> {
let out = args.input;
Ok(out
.map(|a| ReturnValue::Value(Value::Primitive(Primitive::String(serde_json::to_string(&a).unwrap()))))
.boxed())
}