mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-05-11 12:37:34 +02:00
Show case how to use pretty json
This commit is contained in:
@@ -37,7 +37,11 @@ pub fn run() {
|
||||
.plugin(tauri_plugin_os::init())
|
||||
.plugin(tauri_plugin_process::init())
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.plugin(tauri_plugin_store::Builder::default().build())
|
||||
.plugin(
|
||||
tauri_plugin_store::Builder::default()
|
||||
.register_serialize_fn("pretty-json".to_owned(), pretty_json)
|
||||
.build(),
|
||||
)
|
||||
.setup(move |app| {
|
||||
#[cfg(desktop)]
|
||||
{
|
||||
@@ -159,3 +163,9 @@ pub fn run() {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn pretty_json(
|
||||
cache: &std::collections::HashMap<String, serde_json::Value>,
|
||||
) -> Result<Vec<u8>, Box<dyn std::error::Error + Send + Sync>> {
|
||||
Ok(serde_json::to_vec_pretty(&cache)?)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user