DevToys icon indicating copy to clipboard operation
DevToys copied to clipboard

JSON to Code

Open S3bt3r opened this issue 1 year ago • 2 comments

What feature or new tool do you think should be added to DevToys?

A tool that converts JSON data into JSON Schema or classes in various programming languages such as TypeScript and C#. This tool should be capable of analyzing the structure of JSON data and generating corresponding schemas or classes that accurately represent the data structure.

Why do you think this is needed?

This tool would be extremely useful for developers who frequently work with JSON data and need to convert it into different formats for use in various programming languages. It would save time and reduce errors by automating the generation of schemas and classes, ensuring consistency and accuracy in data handling.

Solution/Idea

The tool should have a simple interface where users can paste or upload their JSON data. Upon submission, the tool would provide options to generate JSON Schema or classes in different programming languages like TypeScript, C#, Java, etc. A preview of the generated code should be displayed, and users should be able to copy or download the output.

Comments

An example use case: A developer receives a JSON response from an API and needs to create TypeScript interfaces for type checking. Instead of manually writing the interfaces, they can use this tool to automatically generate the required TypeScript code, saving time and reducing the risk of errors.

S3bt3r avatar Aug 07 '24 07:08 S3bt3r

https://www.nuget.org/packages/DevToys.JsonToCsharp/ exists for C# as an extension. Nice idea to add TypeScript as well.

cloudfy avatar Aug 22 '24 14:08 cloudfy

Hi, I made an extension that contains this functionality(sort of). It doesn't converts Json directly to C#/TypeScript but you can generate a Json schema out of a Json and C#/TypeScript classes out of a Json schema. Hope it helps

benyaa avatar Sep 05 '24 19:09 benyaa

Hello, Thank you all for your suggestion. These extension you folks made are great! Thank you so much for these! I myself used the JSON to C# a few times for my work :D I will close this issue as it's achievable through extensions

veler avatar Oct 21 '24 00:10 veler