Implement json tools
This commit is contained in:
parent
010cbf2447
commit
0398988074
@ -356,8 +356,19 @@ impl AbstractTree for Tool {
|
|||||||
|
|
||||||
Ok(Value::Empty)
|
Ok(Value::Empty)
|
||||||
}
|
}
|
||||||
Tool::FromJson(_) => todo!(),
|
Tool::FromJson(expression) => {
|
||||||
Tool::ToJson(_) => todo!(),
|
let json_value = expression.run(source, context)?;
|
||||||
|
let json = json_value.as_string()?;
|
||||||
|
let value = serde_json::from_str(json)?;
|
||||||
|
|
||||||
|
Ok(value)
|
||||||
|
}
|
||||||
|
Tool::ToJson(expression) => {
|
||||||
|
let value = expression.run(source, context)?;
|
||||||
|
let json = serde_json::to_string(&value)?;
|
||||||
|
|
||||||
|
Ok(Value::String(json))
|
||||||
|
}
|
||||||
Tool::ToString(_) => todo!(),
|
Tool::ToString(_) => todo!(),
|
||||||
Tool::Bash(_) => todo!(),
|
Tool::Bash(_) => todo!(),
|
||||||
Tool::Fish(_) => todo!(),
|
Tool::Fish(_) => todo!(),
|
||||||
|
Loading…
Reference in New Issue
Block a user