Json2CSharp / Json2CSharpCodeGenerator

Microsoft Reciprocal License
292 stars 81 forks source link

Long JSON with fields only visible later in file don't get captured. #75

Closed ghardy2k closed 2 years ago

ghardy2k commented 2 years ago

HI, so my problem may not be unique. if you paste in json that may have, say 1000 records, the class file generated for c# only contains fields that are listed in the first JSON record. But, some API's only return fields IF they are populated. So, 300 records down in the file, you might see fields populated that didn't show up in the first 299 records.

A nice enhancement would be to examine the ENTIRE JSON file, and capture ALL unique fields to generate the class.

thanks!

ghardy2k commented 2 years ago

i just did a test, and put a field down in the file and it did put it at the end of the class.....so i guess this is a feature now.

Json2CSharp commented 2 years ago

yeah this is done by design, I can't handle checking 1000 items for additional properties, the server is going to take a long time to process the data

ghardy2k commented 2 years ago

interesting....i have a json with about 500 records. the first record had a field called manufacturer, so i moved it three records down, so it didn't exist in the first 2 records, and it did add it. maybe you put a limit on how many records it goes through? but i figure i can download that winform app you got up there, and modify that down the road to handle thousands.