Hi
I have the following sample JSON where i want to split it and copy to 2 different datatables like
ID,Name & Description to one table and Distributors data to another table Kindly help me with this
[
{
"Id":"123",
"Name":"abc",
"Description":"abc company",
"Distributors":[
{
"DName":"joe",
"LastName":"BIDEN",
"Email":"[email protected]"
},
{
"DName":"Donald",
"LastName":"TRUMP",
"Email":"[email protected]"
}
]
}
]
Amit MohantyPosted Jan 31, 2024, 10:50 AM
Check this by using Newtonsoft.Json library.
Tuhin PaulPosted Feb 1, 2024, 5:47 PM
I have few refactor pointers worth to mention based on the accepted answer:
1. Explicitly specify data types for columns to improve performance and memory usage.
2. Use StringBuilder for efficient string concatenation, especially for larger datasets.
3. Combine loops and use column-based assignment for readability and potential performance gains.
4. Using dynamic or creating strongly typed classes for better JSON data handling, depending on your usage.
Sam HobbsPosted Feb 1, 2024, 3:45 PM
Prior to .Net Core Newtonsoft was the best choice but the
System.Text.JsonandSystem.Text.Json.Serializationnamespaces are new for .Net Core. If you are using or can use .Net Core then the namespaces provided by .Net Core are likely easier.MeghanaPosted Jan 31, 2024, 12:21 PM
Thank You very much Amit. It worked