c# - Using JSON.NET to return ActionResult -
I am trying to write a C # method that will serialize a model and return a JSON result. Here's my code:
Read public actions ([DataSourceRequest] DataSourceRequest request) {var items = db.Words.Take (1) .ToList (); JsonSerializer settings JsSettings = New JsonSerializer settings (); JsSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; Var changed = JsonConvert.SerializeObject (item, blank, jsSettings); Return Jason (Converted, JasonRakweit Behavior AloGuget); }
When I read in Word / Chrome, I found the following JSON result:
"[[WordId \": 1, \ "rank \ ":", "\", "\", "\", "\", "\", " "ArticleIf" -97ef-4a99-b324-a160295b8ac4 / 1 / sixty_vocab_click_button.mp3 \ ", \" LangID \ ": 1, \" CatId \ ": null, \" isActive \ ": false}
< P> I think that \ "saved quote is a problem that occurs when you sort the object other From the questions: It seems that I am serialing my object twice, because I am first creating serial using JSON.NET and then passing my result in the Jason () function It is necessary to manually serialize me to refer, but I think my view requires ActionResult
How can I return an action result here? Do I need to return a string, or can I return a string?
(Changed, "App / JS") has been suggested;
This works on my very simple page.
Comments
Post a Comment