4,107 questions
i have found the issue:
the controller parse the array value into JArray,and i didn't add newtonjson,so the issue fixed after i use flow code:
services.AddControllers()
.AddNewtonsoftJson(); //add newtonjson
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
when i try to return object with a uncertain value type of dictionary object,the api return a wrong data.
the below is the code:
webapi:
public PagerList<CronJob>GetList(int curPage=1,int pageSize=20) //
{
PagerList<Hello> l = cronJobService.GetPagerList(curPage, pageSize);
return l;
}
Hello Class
public class Hello {
/// <summary>
///
///</summary>
public int Id { get; set; }
/// <summary>
/// name
///</summary>
public string Name { get; set; }
/// <summary>
/// parameter;{}
///</summary>
public Dictionary<string,object> Parameter { get; set; } }
when i call the api,i can get the list like below through debug
[{ "id": 2, "name": "hello", "parameter": { "time": [ 15, 7, 1 ] }}]
but i get the below data through browser
[{ "id": 2, "name": "hello", "parameter": { "time": [ [], [], [] ] } }]
as we see,the parameter attribute is a wrong data.
how can i get the right data?
i have found the issue:
the controller parse the array value into JArray,and i didn't add newtonjson,so the issue fixed after i use flow code:
services.AddControllers()
.AddNewtonsoftJson(); //add newtonjson