"id": "2066000016", "title": { "main": "\ub358\uc804\uc5d0\uc11c \ub9cc\ub0a8\uc744…
- User
"id": "2066000016", "title": { "main": "\ub358\uc804\uc5d0\uc11c \ub9cc\ub0a8\uc744 \ucd94\uad6c\ud558\uba74 \uc548 \ub418\ub294 \uac78\uae4c 3\uad8c", "prefix": "[e\ubd81]" }, "thumbnail": { "small": "https://img.ridicdn.net/cover/2066000016/small#1", "large": "https://img.ridicdn.net/cover/2066000016/large#1", "xxlarge": "https://img.ridicdn.net/cover/2066000016/xxlarge#1" }, "categories": [ { "id": 3001, "name": "\ud574\uc678 \ub77c\ub178\ubca8", "genre": "comic", "sub_genre": "lightnovel", "is_series_category": true, "ancestor_ids": [ 3000, 0 ] } ], "price_info": { "paper": { "price": 0 }, "buy": { "regular_price": 3000, "price": 2700, "discount_percentage": 10 } }
convert to typescript type
- Assistant
Here's a possible TypeScript type for the provided JSON object:
typescripttype Book = { id: string; title: { main: string; prefix: string; }; thumbnail: { small: string; large: string; xxlarge: string; }; categories: { id: number; name: string; genre: string; sub_genre: string; is_series_category: boolean; ancestor_ids: number[]; }[]; price_info: { paper: { price: number; }; buy: { regular_price: number; price: number; discount_percentage: number; }; }; };This defines a
Booktype that has the same shape as the provided JSON object. Thetitle,thumbnail,categories, andprice_infofields are all objects with specific subfields, which are defined in the type. Thecategoriesfield is an array of objects, so its type is an array of objects with the same shape.