James Montemagno
James Montemagno

Live, Love, Bike, and Code.

Live, Love, Bike, and Code

Share


Tags


James Montemagno

Paste JSON as Code with quicktype.io in Visual Studio

quicktype! Yes that quicktype that I blogged about late last year on how to convert JSON to C# classes in the browser. I am back talking about it again because they have made tons of great enhancements and just today released a new extension for Visual Studio 2017! I should mention here that all of this is FREE.

PasteAsCode

Watch Now, Questions Later

Want to see it in action? Checkout my short video overview:

Doesn't VS Do This?

It is true that Visual Studio has a Paste JSON as Classes feature, but it basically does the bare minimum. quicktype will automatically add in JsonProperty names, has enhanced partial classes, better names on parameters, fills in a full class and namespace, and even adds helper classes for you so you don't have to write boiler plate code.

Here is a good example of the power of quicktype. Let's take the Azure Cognitive Services Text Analytics JSON that is returned from the RESTful call.

It is pretty complex JSON with mutliple classes and arrays. If I use the "Special Paste" we do get C# classes back, but they aren't very pretty.

I now have to go through and fix all of the parameter and class names and add in JsonProperty attributes to the tops.

Now let's see the quicktype version:

Now we are talking! Look at those pretty classes and parameters!

Alright, that is enough show an tell for today. Go grab the extension and tell them Motz sent you on their community Slack!

This is NOT sponsored content. I do know the awesome quicktype team and was given early access to the extension. I just believe this is an awesome tool developers should have

Copyright © James Montemagno 2018 All rights reserved. Privacy Policy

View Comments