It happens very often, during the development, to have some objects that are returned by some API and of which we want to create a class.
If the object are big with a lot of subnodes, it should be a long activity and, first of all, very annoying.
The Visual Studio team improved this feature in the last version of the IDE.
How to use this feature
Create an empty class or just a file with the namespace declaration.
Then you can copy your JSON into the clipboard and in Visual Studio go to Edit -> Paste Special -> Paste JSON as Classes
This feature is very fast right now. With the previous version of Visual Studio, sometimes, you had issues to create a class from a big JSON file.
Keyboard Shortcut
By default this command is not associated to any keyboard shortcut.
In my environment I configured that from the menu Tools -> Options.
I choosen Ctrl+V, Ctrl+J but you can choose your favourite shortcut for this special action.
Top comments (0)