1
2
3
4
5
6
7
8
9
10
11
//! # json
//! a re-export of serde_json with error wrapping and only operates on Result<T, E> where T & E impl Serialize

use serde::Serialize;

use super::error::Error;

/// a simple re-export wrapper of serde_json::to_string for Result<T, E>
pub fn json<T: Serialize, E: Serialize>(result: &Result<T, E>) -> Result<String, Error> {
    Ok(serde_json::to_string(result)?)
}