JSON to Rust Struct: hướng dẫn bắt đầu nhanh
Mọi thứ bạn cần cho lần dùng thành công đầu tiên: dán gì vào, tùy chọn nào thực sự quan trọng, và đọc kết quả ra sao.
Cách dùng
- Mở công cụ và dán dữ liệu vào khung bên trái.
- Chỉ chỉnh những tùy chọn mà tác vụ thực sự cần — giá trị mặc định đã đúng cho hầu hết trường hợp.
- Đọc kết quả ở khung bên phải; kết quả cập nhật khi bạn gõ.
- Dùng Sao chép để lấy kết quả, hoặc Tải xuống để lưu thành tệp.
Ví dụ
Emits serde rename attributes so the Rust field names can stay idiomatic.
Đầu vào
{"id":42,"title":"Hello","tags":["a","b"],"active":true}
Đầu ra — Kết quả
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,
}
Chạy
Mô tả
Generate a serde-derived Rust struct with rename attributes from a JSON sample.
JSON to Rust Struct → · Cách dùng → · Công cụ chuyển đổi dữ liệu →
Công cụ liên quan
Bộ chuyển đổi CSV to JSONTurn CSV (or any delimited file) into a JSON array.Bộ chuyển đổi YAML to JSONParse YAML configuration into JSON.Bộ chuyển đổi HTML to MarkdownConvert HTML fragments into Markdown.Bộ chuyển đổi JSON to TOMLConvert JSON config into TOML format.Bộ chuyển đổi Markdown to HTMLRender Markdown to clean HTML.Bộ chuyển đổi DelimiterSwitch CSV between comma, tab, semicolon and pipe.