We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Json to typescript or possibaly multiple language classes or interfaces conversion
its everyday job. i use - https://app.quicktype.io/
https://app.quicktype.io/
No response
The text was updated successfully, but these errors were encountered:
bash npm install quicktype-core
js const { quicktype, InputData, jsonInputForTargetLanguage } = require("quicktype-core");
/**
Convert JSON to TypeScript interface.
@param {string} jsonData - The JSON data string to convert.
@returns {string} - The generated TypeScript code. */ async function convertJsonToTypescript(jsonData) { try { const inputData = new InputData(); const jsonInput = jsonInputForTargetLanguage("typescript");
// Add the JSON data to the InputData inputData.addSource({ name: "MyModel", samples: [jsonData] });
// Generate TypeScript from JSON const { lines } = await quicktype(inputData, "MyModel", { lang: "typescript" }); return lines.join("\n"); } catch (error) { console.error("Error converting JSON:", error); } }
// Example JSON const jsonData = { "name": "John Doe", "age": 30, "isActive": true };
{ "name": "John Doe", "age": 30, "isActive": true }
convertJsonToTypescript(jsonData).then((typescriptCode) => { console.log(typescriptCode); });
Sorry, something went wrong.
No branches or pull requests
What feature or new tool do you think should be added to DevToys?
Json to typescript or possibaly multiple language classes or interfaces conversion
Why do you think this is needed?
its everyday job. i use - https://app.quicktype.io/
Solution/Idea
https://app.quicktype.io/
Comments
No response
The text was updated successfully, but these errors were encountered: