从JSON排除Odata元数据和类型 [英] Exclude Odata metadata and type from JSON
本文介绍了从JSON排除Odata元数据和类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面的脚本从我的ODataController返回JSON
The script below return a JSON from my ODataController
< script >
$(document).ready(function() {
$.ajax({
url: "http://localhost:37994/odata/EPStructures3/",
type: "Get",
contentType: 'application/json; charset=utf-8',
success: function(data)
{
//do something.....
},
error: function(msg)
{
alert(msg);
}
});
});
< /script>
JSON:
{ "odata.metadata":"http://localhost:37994/odata/$metadata#EPStructures3","value":[{"eps_level":0,"id":2},{"eps_level":1,"id":3}]}
我想排除元数据并输入类型,以便这样返回JSON:
I want to exclude the metadata and type so the JSON is returned like this:
[{"eps_level":0,"id":2},{"eps_level":1,"id":3}]
我该如何实现?
推荐答案
如果在请求中添加"Accept:application/json; odata.metadata = none"标头,则将尽可能接近您想要的内容
If you add an "Accept: application/json; odata.metadata=none" header to your request you will get as close as you can to what you want.
这篇关于从JSON排除Odata元数据和类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文