I have a list and an array that I would like to return, but I'm unsure how to bring the two together. I have deserialized my JSON and created two objects. How do I bring this list and array together in a single object? :
var one = JsonConvert.DeserializeObject<MyData.RootObject>(first);
var two = JsonConvert.DeserializeObject<MyData.RootObject>(second);
List<myData.DataOne> listOne = new List<myData.DataOne>();
foreach (var items in one)
{
someDataModel model = new someDataModel();
model.property = one.rows.f[0].v;
listOne.Add(model);
}
string[] array = new string[two.rows.Count];
for (var items = 0; items < two.rows.Count; items++)
{
array[items] = two.rows[items].f[0].v;
}
return null;
Create a new class to represent the combination of these two pieces of data:
public class MyReturnType
{
public List<myData.DataOne> ListOne {get;set;}
public string[] Array {get;set;}
}
Then return it:
return new MyReturnType {ListOne = listOne, Array = array};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With