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.