AI generated prompt for TypeScript Interface from JSON
**Context**:
You are given a JSON object that represents the structure of a TypeScript interface. The JSON object contains property names as keys and their corresponding data types as values. Your task is to create a TypeScript interface based on this JSON object.
**Detailed Instructions**:
1. Parse the provided JSON object and extract the property names and their corresponding data types.
2. Use the extracted information to create a TypeScript interface. The interface should have the same property names as the keys in the JSON object, and the data types of these properties should match the values in the JSON object.
3. Ensure that the generated TypeScript interface is syntactically correct and can be used in a TypeScript environment.
4. If the JSON object contains nested objects, the corresponding TypeScript interface should have properties with types that are also interfaces, representing the nested structure.
**Output Format**:
The output should be a string representing the TypeScript interface definition. The string should be formatted according to TypeScript syntax rules and should include all the properties defined in the JSON object.
**Examples**:
If the input JSON object is:
```json
{
"name": "string",
"age": "number",
"address": {
"street": "string",
"city": "string",
"state": "string",
"zip": "string"
}
}
```
The output TypeScript interface should be:
```typescript
interface Address {
street: string;
city: string;
state: string;
zip: string;
}
interface RootInterface {
name: string;
age: number;
address: Address;
}
```
If the input JSON object is:
```json
{
"id": "number",
"productName": "string",
"prices": {
"usd": "number",
"eur": "number"
}
}
```
The output TypeScript interface should be:
```typescript
interface Prices {
usd: number;
eur: number;
}
interface Product {
id: number;
productName: string;
prices: Prices;
}
```This coding prompt is designed to help you get better results from AI assistants like ChatGPT, Claude, and Gemini. Here's how to make the most of it:
💡 Pro tip: Save this prompt to your collection to use it again later. Well-crafted prompts can save hours of back-and-forth with AI.
Adjust the prompt to match your specific industry, audience, or use case. Adding relevant context improves output quality.
Specify your desired output length (e.g., "in 200 words" or "in 3 bullet points") to get more targeted responses.
Add tone instructions like "professional," "casual," or "technical" to match your brand voice.
Include an example of the output format you want to help the AI understand your expectations.
This prompt has been tested and optimized for all major AI models. For best results with coding-related prompts, consider using an AI-powered IDE like Cursor or Windsurf.
Learn more about using prompts effectively with our comprehensive guides:
0 people found this prompt helpful
Based on 0 reviews
Be the first to share your experience with this prompt!
This prompt was reviewed and verified to work with current AI models.
Tested with ChatGPT, Claude & Gemini. Reviewed by community users.
AI prompts work best when you customize them for your specific situation. Follow these steps to get the most out of TypeScript Interface From JSON.