JSON ➡️ TypeScript

JSON ➡️ TypeScript

Input
{
  "id": 102,
  "name": "Mi 13 Ultra",
  "metadata": "{\"RAM\":\"12GB\",\"Storage\":\"12GB\",\"Color\":\"Green\"}",
  "stock": 68,
  "price": 699.99,
  "featured": true,
  "reviews": [
    {
      "id": 897,
      "userId": 123,
      "rating": 9,
      "content": "Good",
      "publishedAt": "2024-12-14T14:48:49.802Z"
    },
    {
      "id": 426,
      "userId": 75,
      "rating": 8,
      "content": "Not bad",
      "publishedAt": "2024-12-14T14:48:49.802Z"
    }
  ]
}

Output
export interface Type {
  id:       number;
  name:     string;
  metadata: Metadata;
  stock:    number;
  price:    number;
  featured: boolean;
  reviews:  Review[];
}

export interface Metadata {
  RAM:     string;
  Storage: string;
  Color:   string;
}

export interface Review {
  id:          number;
  userId:      number;
  rating:      number;
  content:     string;
  publishedAt: string;
}