Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
As title , is any way can do it ?
Yep..You can find the docs here : http://our.umbraco.org/documentation/Reference/WebApi/
Thanks dawoe, But my question is the output have unnecessary element. I want to pure string.
What do you mean with unnecessary element ?
I figure out now.. no unnecessary element.
The browser behavior seems a little bit difference.
Chrome:
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">{"boolean": true,"string": "Hello World"}</string>
Firefox :
<string>{"boolean": true,"string": "Hello World"}</string>
IE & jQuery method get result is good.
{"boolean": true,"string": "Hello World"}
Very thanks.
http://stackoverflow.com/questions/9847564/how-do-i-get-asp-net-web-api-to-return-json-instead-of-xml-using-chrome
I implemented the removal of the xml formatter but am still getting xml back..
any suggestions?
Try to add the right Content-Type request-header with a value of "application/json".
the easy way.
[HttpGet]
public HttpResponseMessage GetJson()
{
HttpContext.Current.Response.ContentType = "application/json";
HttpContext.Current.Response.Write("{\"status\":\"OK\"}");
return new HttpResponseMessage();
}
This code worked for me Exactly what I need to output pure json data back from the WebApi controller
cheers
Hey gwweee,
I'm trying to do the same thing with but to render a list of children under a specific node which will show only a single property value in the JSON.
Can't seems to figure out how this is done with the UmbracoApiController. Any help will be much appreciated
what's your code?
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Get JSON output by UmbracoApiController
As title , is any way can do it ?
Yep..You can find the docs here : http://our.umbraco.org/documentation/Reference/WebApi/
Thanks dawoe, But my question is the output have unnecessary element. I want to pure string.
What do you mean with unnecessary element ?
I figure out now.. no unnecessary element.
The browser behavior seems a little bit difference.
Chrome:
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">{"boolean": true,"string": "Hello World"}</string>
Firefox :
<string>{"boolean": true,"string": "Hello World"}</string>
IE & jQuery method get result is good.
{"boolean": true,"string": "Hello World"}
Very thanks.
http://stackoverflow.com/questions/9847564/how-do-i-get-asp-net-web-api-to-return-json-instead-of-xml-using-chrome
I implemented the removal of the xml formatter but am still getting xml back..
any suggestions?
Try to add the right Content-Type request-header with a value of "application/json".
the easy way.
[HttpGet]
public HttpResponseMessage GetJson()
{
HttpContext.Current.Response.ContentType = "application/json";
HttpContext.Current.Response.Write("{\"status\":\"OK\"}");
return new HttpResponseMessage();
}
This code worked for me Exactly what I need to output pure json data back from the WebApi controller
cheers
Hey gwweee,
I'm trying to do the same thing with but to render a list of children under a specific node which will show only a single property value in the JSON.
Can't seems to figure out how this is done with the UmbracoApiController. Any help will be much appreciated
what's your code?
is working on a reply...