Skip to main content

JsonResult

Type Alias JsonResult 

Source
pub type JsonResult = Result<Value, Value>;
Expand description

A shorthand for a json result.

This is useful when you want to return a json response. It is a type alias for a Result with a Value as the ok and error type.

§Example

ⓘ
use serde_json::json;
use ngyn::prelude::*;

#[handler]
async fn get_values() -> JsonResult {
    let data = json!({ "key": "value" });
    Ok(data)
}

Aliased Type§

pub enum JsonResult {
    Ok(Value),
    Err(Value),
}

Variants§

§1.0.0

Ok(Value)

Contains the success value

§1.0.0

Err(Value)

Contains the error value