从jsonarray移除元素 [英] remove element from jsonarray

查看:1768
本文介绍了从jsonarray移除元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像下面这样的json:

{
"SeriesId":",
"ContentId":"10001",
"PolicyGroupId":"1234",
"ChannelId":"231",
标题":权力的游戏",
"Number":"1",
"IsAuthorized":"true | false",
描述":史诗第1季,屡获殊荣的HBO系列权力的游戏"",
"DurationSeconds":"1800",
"LinearStartDateTime":"2013-03-12T00:35:00Z",
图片":{
类型":缩略图",
网址":"http://www.elysium-uk.com/site/wp-content/uploads/2012/04/Game-of-Thrones-Season-2-Teaser.jpg"
}

我想删除一些节点,例如ChannelId,Number等.删除json节点的方法是什么?

请指导.

谢谢

I have a json like the following:

{
"SeriesId": "",
"ContentId" : "10001",
"PolicyGroupId" : "1234",
"ChannelId": "231",
"Title" : "Game of Thrones",
"Number" : "1",
"IsAuthorized": "true|false",
"Description" : "Season 1 of the epic, award winning HBO series \"Game of Thrones\"",
"DurationSeconds": "1800",
"LinearStartDateTime": "2013-03-12T00:35:00Z",
"Images" : {
"Type": "Thumbnail",
"Url": "http://www.elysium-uk.com/site/wp-content/uploads/2012/04/Game-of-Thrones-Season-2-Teaser.jpg"
}

I want to remove some of nodes like ChannelId, Number etc. What is the way to remove json nodes?

Please guide.

Thanks

推荐答案

是从stackoverflow复制的

Copied from stackoverflow

function findAndRemove(array, property, value) {


.each(array, function(index, result) { if(result[property] == value) { //Remove from array array.splice(index, 1); } }); } //Checks countries.result for an object with a property of ''id'' whose value is ''AF'' //Then removes it ;p findAndRemove(countries.results, ''id'', ''AF'');
.each(array, function(index, result) { if(result[property] == value) { //Remove from array array.splice(index, 1); } }); } //Checks countries.result for an object with a property of ''id'' whose value is ''AF'' //Then removes it ;p findAndRemove(countries.results, ''id'', ''AF'');



链接 [^]



Link [^]


这篇关于从jsonarray移除元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆