Json2CSharp / Json2CSharpCodeGenerator

Microsoft Reciprocal License
305 stars 83 forks source link

Some C# classes created from Json have invalid name #113

Open JaySchwarz opened 9 months ago

JaySchwarz commented 9 months ago

I'm trying to interface with an API that uses lots of field names that are all numeric. In most cases, the Json->C# tool does a great job of starting the field or class name with an underscore, but not always.

Here is a sample of what I'm seeing in Visual Studio after I copy in the class from the clipboard. This is my first project using JSON with a 3rd Party API, so maybe I'm doing something wrong. Thanks. Otherwise, I love the tool!

public class _949956117 { public string value { get; set; } public string name { get; set; } }

public class 1216986445 { public string field_type { get; set; } public string street_address { get; set; } public string city { get; set; } public string state { get; set; } public string zip { get; set; } public string longitude { get; set; } public string latitude { get; set; } public string is_primary { get; set; } public string is_private { get; set; } }

public class 1995837313
{
    public string address { get; set; }

public string is_primary { get; set; }

Json2CSharp commented 9 months ago

yeah this is a problem with dictionaries, the tool does not detect dictionaries, it can be done using markov chain or some AI technique but this needs development