I have many Gb of json data, but I dont know the complete json structure looks. I need to make classes of the content so I can load it in to a database instead and make data processing. The problem is that most likely there is quite likely more than 100 json properties that just being used maybe handfull of times. How do I create these entity classes? My suggestion that I just read the entire file to just create the entities first, but how? Somekind reflection of the current json.net result? There is many 100 subarrays in each object. I tried to search both google and stackoverflow for this, but I could not find any good clues. But I dont belive I am the first to have this kind of problem...
Asked
Active
Viewed 99 times
0
-
There a few ways to do this. But you will need a sample of the json to generate the classes – Jonathan Alfaro May 05 '21 at 20:37
-
Yes I know.. but I dont have a sample json that contains all the keyvaluepairs. I have to go throu the entire file to get the correct entity pairs/arrays and then generate the entities. – Jerker Pihl May 05 '21 at 20:47
-
1Not enough information to answer the question. You can try loading into a `JToken` but the memory use might be enormous. Is your outer JSON container an array? If so then lazily enumerating through the array might be a valid solution. If you have a collection of objects that share a bunch of common properties but may have extra data, you could define a class for the common properties and use `JsonExtensionData` for the rest. See [How to serialize a Dictionary as part of its parent object using Json.Net](https://stackoverflow.com/q/14893614/3744182). – dbc May 05 '21 at 21:19
-
Yes the file containing json is too large (5,1Gb) to load to memory. Add yes there is common json properties inside this array. I will try to make a custom JsonExtensionData and hopefully after I have gone through the file I will have a more complete set of properties of the Json file. Thank you,,, this might be a way to a solution. – Jerker Pihl May 17 '21 at 13:08