c# - How to output Json string as JsonResult in MVC4? -


this seems simple must over-thinking it.

tl;dr;

how can modify code below return json object contained in string rather string happens contain json?

public actionresult test() {   var json_string = "{ success: \"true\" }";   return json(json_string, jsonrequestbehavior.allowget); } 

this code returns string literal containing json:

"{ success: "true" }" 

however, i'd return json contained in string:

{ success: "true" } 

slightly longer version

i'm trying prototype external api calls , want pass results through "api" fake response now. json object non-trivial - on order of 10,000 "lines" or 90kb. don't want make typed object(s) contents of 1 json response can run through deserializer - out.

so basic logic in controller is:

  1. call externall api
  2. store string result of web request var (see json_string above)
  3. output results json (not string) using jsonresult producing method json()

any appreciated... mind melting.

the whole point of json() helper method serialize json.

if want return raw content, directly:

return content(jsonstring, "application/json"); 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -