Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paste JSON as Classes not following C# naming conventions

Say I had the following json

{
    "employees": [{
            "firstName": "John",
            "lastName": "Doe"
        }, {
            "firstName": "Anna",
            "lastName": "Smith"
        }, {
            "firstName": "Peter",
            "lastName": "Jones "
        }
    ]
}

When I use Edit > Paste JSON as Classes the following class gets created:

namespace JSONUtils
{

        public class Employee
        {
            public string firstName { get; set; }
            public string lastName { get; set; }
        }

        public class Example
        {
            public IList<Employee> employees { get; set; }
        }

}

Notice the string firstName, this should be FirstName. Is there a way of Visual Studio sticking to naming convention rules?

The following site helps do this, but would be great if this was in VS: https://jsonutils.com/

like image 917
thatOneGuy Avatar asked Sep 06 '25 06:09

thatOneGuy


1 Answers

Is there a way of Visual Studio sticking to naming convention rules?

Alas no. There is no way of customising this (in Visual Studio, unless you install extra plugins / extensions).

Your best bet is to keep using https://jsonutils.com or https://app.quicktype.io/#l=cs&r=json2csharp (or one of the plugins / extensions).

like image 69
mjwills Avatar answered Sep 09 '25 01:09

mjwills