Skip to content

JSON से TypeScript

नमूना JSON को TypeScript इंटरफ़ेस या टाइप एलियास में बदलें, नेस्टेड ऑब्जेक्ट, ऐरे और वैकल्पिक फ़ील्ड पहचाने जाते हैं।

कोई अपलोड नहीं
export interface Root {
  id: number;
  name: string;
  email: string;
  active: boolean;
  tags: string[];
  address: Address;
  orders: Order[];
}

export interface Order {
  id: string;
  total: number;
  coupon?: string;
}

export interface Address {
  city: string;
  zip: null;
}

JSON से TypeScript कैसे इस्तेमाल करें

  1. 1JSON से TypeScript खोलें। यह आपके ब्राउज़र में चलता है, साइन-अप की ज़रूरत नहीं।
  2. 2अपना इनपुट टाइप या पेस्ट करें।
  3. 3नतीजा कॉपी या डाउनलोड करें।

सवाल

How are optional fields detected?

When an array contains objects and a key is missing from some of them, that key is marked optional with ?.

What about null values?

null is kept in a union, e.g. string | null, so you can see which fields can be empty.

Is my JSON uploaded?

No — conversion happens entirely in your browser.

और टूल