Skip to content
New issue

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 Code #6

Open
veler opened this issue Sep 30, 2021 · 9 comments
Open

JSON to Code #6

veler opened this issue Sep 30, 2021 · 9 comments
Labels
feature Feature / Tool request or idea
Milestone

Comments

@veler
Copy link
Collaborator

veler commented Sep 30, 2021

Is your feature request related to a problem? Please describe.
As a web developer, it common to have to convert a large JSON to C# classes in order to consume certain web API.

Describe the solution you'd like
Add a JSON to C#, TypeScript and Java tool.

@veler veler added the enhancement Idea of improvement of existing feature. label Sep 30, 2021
@veler veler changed the title JSON To CSharp JSON To Class Oct 12, 2021
@itsWindows11
Copy link

Could I work on this?

@veler
Copy link
Collaborator Author

veler commented Nov 5, 2021

With pleasure!

Some guidance:

  1. Feel free to make your own solution for the conversion, or take example on existing implementation on GitHub. Just be mindful of the license. I'd like to keep DevToys under MIT license, so I'd avoid anything that has a license requiring us to publish DevToys under the same than their.
  2. Keep things simple, for now. I'd prefer shipping a converter with a minimal set of languages and options for it than delivering a lot options right at the beginning. For example, for C#, I think the following options to start should be enough:
    • Should array be treated as [] or List
    • Should properties support nullable values or not
  3. Follow the coding style guidance here: https://github.com/veler/DevToys/blob/main/CONTRIBUTING.md#coding
  4. Let's start with JSON to C# and TypeScript first. Let's see in a future iteration for other languages like Java, Python or C++
  5. Let's support Smart Detection feature. Here is an example: https://github.com/veler/DevToys/blob/d6cf9414110d9fecf4c2c44af8df74074ea1def4/src/dev/impl/DevToys/ViewModels/Tools/JsonFormatter/JsonFormatterToolProvider.cs#L29-L32
  6. When designing the UI
    • Consider using the monaco editor like in Json Formatter or Json <> Yaml tool.
    • If you need more than 3 options in the UI, consider an expandable one, like in Regex Tester tool
    • Make sure to test the UI in compact mode, maximized window and small (width and height) window side.

Don't hesitate to ask questions here or ping me on Discord :)
Thank you so much for wanting to participate :D

@JaiganeshKumaran
Copy link
Contributor

Visual Studio already has an option for this under the Edit menu.

@veler
Copy link
Collaborator Author

veler commented Dec 4, 2021

@JaiganeshKumaran , thank you :)
What you're saying is true, but it lacks a few options to define, for example, whether we want PascalCase, camelCase, and more options that we can find on websites online.
We're trying to bring the power of these online service into an offline app, not to limit ourselves to what Visual Studio already does.

@nartalex
Copy link

Hi guys! Is there any chance to see Class to JSON converter? I'd love to use it for API testing

@veler
Copy link
Collaborator Author

veler commented Jan 20, 2022

By Class to Json, to you mean generating mocked JSON value from a class definition?

@nartalex
Copy link

Exactly. I see this as a input window for my C# class and (maybe) a JSON constructor where I can pick values I need in my JSON.
I mentioned that because I often test my APIs by Postman and I always struggle with converting my API's input model into JSON especially a large ones.
That initial conversion can be done by Swagger, but Swagger generates model as full as it can be, so I have to manually clean it and that can be very time consuming

@itsWindows11
Copy link

I kinda implemented it with NJsonSchema on a sample console app but the output is messy, still have to port it to the app.

@veler veler added this to the v2.0 milestone Dec 31, 2022
@veler veler changed the title JSON To Class JSON to Code Dec 31, 2022
@veler
Copy link
Collaborator Author

veler commented Dec 31, 2022

[December 2022 update]

This could be a potential paid feature for DevToys 2.0.

UX could be as simple as:

Input:
JSON

Output:
TypeScript, Python, Java, C#, PHP, C++, Ruby, Go, Dart, Rust, Swift

Settings:
They would be specific to each output language selected. For example, for C#, we could allow to chose whether a [JSONProperty] attribute should be added.

@veler veler added feature Feature / Tool request or idea and removed enhancement Idea of improvement of existing feature. labels Mar 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature / Tool request or idea
Projects
None yet
Development

No branches or pull requests

4 participants