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 JSONTurn CSV (or any delimited file) into a JSON array.ตัวแปลง YAML to JSONParse YAML configuration into JSON.ตัวแปลง HTML to MarkdownConvert HTML fragments into Markdown.ตัวแปลง JSON to TOMLConvert JSON config into TOML format.ตัวแปลง Markdown to HTMLRender Markdown to clean HTML.ตัวแปลง DelimiterSwitch CSV between comma, tab, semicolon and pipe.