neon::types::extract

Module json

Source
Available on crate feature serde only.
Expand description

Extract JavaScript values with JSON serialization

For complex objects that implement serde::Serialize and serde::Deserialize, it is more ergonomic–and often faster–to extract with JSON serialization. The Json extractor automatically calls JSON.stringify and JSON.parse as necessary.

use neon::types::extract::Json;

#[neon::export]
fn sort(Json(mut strings): Json<Vec<String>>) -> Json<Vec<String>> {
    strings.sort();
    Json(strings)
}

Structs§

  • Error returned when a value is invalid JSON
  • Wrapper for converting between T and JsValue by serializing with JSON.