And then the controller [HttpGet] Public stringGet () { Return XXX. ToJson (); Here in directing a conversion of data, debugging is normal json structure ok }
But running F12 found out is the text of the content-type is text/plan
Then add [Produces the controller (" application/json ")], was transformed
But json is received after forced to escape the json, can use
[HttpGet] Public JsonResult the Get () {
Return new JsonResult (xxxObject);//xxxObject class object is the original }
Try to find is indeed a json, but the json object is empty, only a large number, and {}
Then try to return objects directly
[HttpGet] Public xxxObjectGet () {
Return xxxObject;//xxxObject class object is the original }
Find it empty and JsonResult, json {}
Seek advice on how to use the.net 5 to create a simple get request, can return the json,
Thank you, I feel so can achieve a simple function, some depressed,
On the Internet looking for example is essentially a few years ago WEB Form, with no
Thank you,
CodePudding user response:
Try
[httpGet] Public dynamic Test () { Return new {id=1}; }
CodePudding user response:
public string the Get () { Return JsonConvert. SerializeObject (result); } //receipt of each other, JsonConvert. DeserializeObject