Tipik bir REST API JSON yanıtından serde derives ile Rust struct'ları üretin. Anında çıktı üretir, tarayıcıda çalışır, sunucuya veri gönderilmez.
// Generated by DevBento — json-to-typescript
interface RootAddress {
street: string;
city: string;
zip: string;
}
interface RootPostsItem {
title: string;
likes?: number;
}
interface Root {
id: number;
name: string;
email: string;
isActive: boolean;
roles: string[];
address: RootAddress;
posts: RootPostsItem[];
}Bu örnek, tipik bir REST API yanıtından serde derives ile Rust struct’ları üretir. Önceden doldurulmuş JSON, iç içe adres, roller dizisi ve yazı nesneleri dizisi olan bir kullanıcı nesnesini temsil eder. Rust moduna geçerek üretilen struct’ları görün.
Araç şunları üretir:
Root struct’ıRootAddress struct’ıRootPostsItem struct’ı#[derive(Serialize, Deserialize)]#[serde(rename)] nitelikleriOption<T> (örneğin Likes eksik olan Posts öğeleri)String, i64, bool, Vec<String>, serde_json::Valueserde derives ile Rust struct’ları, Rust’ta API yanıtlarını serileştirmenin standart yoludur. Üretilen kod doğrudan serde_json::from_str ve serde_json::from_value ile çalışır. Yanıtta her zaman bulunmayan alanlar için Option<T> kullanın.
Nothing you paste leaves this tab. Every tool runs entirely in your browser — no upload, no server, no account.