Json2CSharp / Json2CSharpCodeGenerator

Microsoft Reciprocal License
292 stars 81 forks source link

Feature Request: Add a check box for making all the C# values strings. #69

Closed 17SchallerJ closed 2 years ago

17SchallerJ commented 2 years ago

Can you add an option to generate all C# object with all string values? Or an option to make the default for unknown types string instead of object?

IE. if I have some json like this {"field1":0, "field2":null, "field3":"stringValue",...} instead of generating: int field1, object field2, string field3... could you make it generate: string field1, string field2, string field3... or at the least generate: int field1, string field2, string field3...

Sorry if the title is bad, or if I explained things poorly. I don't usually make submissions to GitHub Projects. I will try to remember to check back on this page in case you ask any questions, but I apologize if I forget. Thanks!

aloksharma1 commented 2 years ago

your suggestion is actually against the core design principals of how strongly typed objects should be handled in a c# poco class, then again maybe a override can be added to treat all objects as string but this is very bad design-wise.

Json2CSharp commented 2 years ago

yeah I agree with aloksharma, its better to have the types convert to strongly typed objects