JSONtoRustStruct:快速上手指南
第一次使用就能成功所需的全部内容:该粘贴什么、哪个选项真正重要、以及如何读懂结果。
使用方法
- 打开工具,将内容粘贴到左侧输入框。
- 只调整任务真正需要的选项——多数情况下默认值就是正确的。
- 在右侧查看结果,输入时结果会实时更新。
- 用「复制」取走结果,或用「下载」保存为文件。
示例
Emits serde rename attributes so the Rust field names can stay idiomatic.
输入
{"id":42,"title":"Hello","tags":["a","b"],"active":true}
输出 — 搜索结果
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Root {
#[serde(rename = "id")]
pub id: i64,
#[serde(rename = "title")]
pub title: String,
#[serde(rename = "tags")]
pub tags: Vec<String>,
#[serde(rename = "active")]
pub active: bool,
}
运行
说明
Generate a serde-derived Rust struct with rename attributes from a JSON sample.
相关工具
CSV to JSON 转换器Turn CSV (or any delimited file) into a JSON array.YAML to JSON 转换器Parse YAML configuration into JSON.HTML to Markdown 转换器Convert HTML fragments into Markdown.JSON to TOML 转换器Convert JSON config into TOML format.Markdown to HTML 转换器Render Markdown to clean HTML.Delimiter 转换器Switch CSV between comma, tab, semicolon and pipe.