I got the following error while trying to add an object of type class to the JArray.
Could not determine JSON object type for type "Class"
Here is the code that I am using:
private dynamic _JArray = null
private JArray NArray(Repository repository)
{
_JArray = new JArray();
string[] amounts = repository.Amounts.Split('|');
for (int i = 0; i <= amounts.Length; i++)
{
_JArray.Add(
new AmountModel
{
Amounts = amounts[i],
});
}
return _JArray;
}
public class AmountModel
{
public string Amounts;
}
And I call it like the following when run the program:
_JArray = NArray(repository);
Console.WriteLine(JsonConvert.SerializeObject(_JArray));
How can I convert the AmountModel (class) inside of _JArray (JArray), to be recognized by the system as JSON object?
Your answer much appreciated.
Thank you.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…