Closed mikaelollhage closed 2 years ago
Use .ThrowAndStopOnMissingField(false)
on CSVWriter, as the 2 objects are having mixed structure.
Here is working sample: https://dotnetfiddle.net/5Ppv1t
Hi!
Thanks for getting back to me so quickly! Very impressive! I have looked at your suggestions. It does in fact now get me all rows, however it loses the properties not included in the first object - the three in the TestEquipment objects in this example (not in the header either).
Is there a way around this too?
Thanks again!
BR, MO
Use .WithMaxScanRows(2)
on CSVWriter to pick those nodes.
Updated working sample: https://dotnetfiddle.net/j8lmFA
Thanks again! This nuget truly is amazing compared to the others out there.
So, since this is a generic method with objects coming in from a database, I can never know which rows has which properties filled. So I guess I need to scan my whole list to be certain that I get all properties? Or is there a way to populate/write the header based on the model
well, if you know the model of the message, you can construct the classes from them and use it for your parsing. This will eliminate the scanning process.
Otherwise, you have no choice to scan the entire list to capture all data.
Thank you my friend. It is a generic method that serves several completely different models in this case, so I will go aheadwith the full scan instead.
Thanks again for your amazing help!
BR, MO
Hi,
I have a situation where not my whole json gets parsed into csv-format.
Code
I have an example json below containing 2 objects in an array. Only the first object gets parsed. In my real life example I have multiple objects under the ones supplied here. As long as I have the first object in the json, then that object is the only object that gets parsed. If I remove it, all other objects suddenly gets parsed flawlessly. So my guess is that it must contain som kind of escape?
For me it is unclear if it is the reader or the writer that fails.
Thank you kindly!
BR, MO