rust - 序列化时跳过结构字段

标签 rust serde

给定结构:

#[derive(Debug, Serialize)]
pub struct ReqMetrics {
    start: Timespec,
    pub name: String
}

如何确保 Serde 在序列化时忽略字段 start

最佳答案

正确的注释是#[serde(skip_serializing)] .

关于rust - 序列化时跳过结构字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42241033/

相关文章:

rust - rust 中的项目结构——添加额外文件

rust - rust 中函数接受闭包作为参数或返回闭包的惯用方式是什么?

Rust,如何执行基本的递归异步?

json - 错误 : the type of this value must be known in this context (Rust)/serde_json Value

rust - 从字节字符串中提取MsgPack- rust

rust - Json<T> 是如何工作的(表单数据没有表单内容类型)

rust - 使用空对象作为值反序列化映射

dictionary - 如何重命名serde_json::Map中的所有键?

rust - 无法在Rust中显示struct的显示

serialization - 如何将 BSON 反序列化为通用对象?