当向客户端发送json数据时,我得到这样的数据。
{"Data":{"rows":[{"id":1,"cell":["1","amila","amila","False"]},{"id":2,"cell":["2","rakhitha","rakhitha","False"]},{"id":3,"cell":["3","Chathura","Chathura","False"]},{"id":4,"cell":["4","Geethaga","Geethaga","False"]}]},"JsonRequestBehavior":0}
但我想获取没有“Data”属性的数据。像这样,
{"rows":[{"id":1,"cell":["1","amila","amila","False"]},{"id":2,"cell":["2","rakhitha","rakhitha","False"]},{"id":3,"cell":["3","Chathura","Chathura","False"]},{"id":4,"cell":["4","Geethaga","Geethaga","False"]}]}
如何从json对象中删除此“数据”部分?有可能吗?
我从此网址访问此数据。 API / matchingservicewebapi /的getUser
答案 0 :(得分:6)
这样做:
var json = {"Data":{"rows":[{"id":1,"cell":["1","amila","amila","False"]},{"id":2,"cell":["2","rakhitha","rakhitha","False"]},{"id":3,"cell":["3","Chathura","Chathura","False"]},{"id":4,"cell":["4","Geethaga","Geethaga","False"]}]},"JsonRequestBehavior":0};
json = json.Data;
答案 1 :(得分:1)
使用
<script >
var data = yourJson.data
</script>
答案 2 :(得分:1)
如果您管理服务器(在url:api / matchingservicewebapi / GetUser上),您需要更改那里的输出。
答案 3 :(得分:1)
例如,如果您在results
变量中获得JSON结果,则可以执行results = results.Data
。