关于编辑json字符串的问题

这样一个json字符串怎么在代码中把result那一级个去掉?(就是把字符串"result":{}去掉)
{
"jsonrpc":"2.0",
"id":"10",
"result":
{
"resultList":
[{
"name": "1",
"agentName": "sdfsf",
"address": "Ed Spencer",
"workMethod": "22",
"phone": "blue",
"mobilePhone": "sdfdsf",
"workLicenseId": "sdfsdf",
"workLicenseIssueDate": "2012-03-23",
"workLicenseInvalidateDate": "2015-03-23"
},
{
"name": "2",
"agentName": "sdfsf",
"address": "Ed Spencer",
"workMethod": "22",
"phone": "blue",
"mobilePhone": "sdfdsf",
"workLicenseId": "sdfsdf",
"workLicenseIssueDate": "2012-03-23",
"workLicenseInvalidateDate": "2015-03-23"
},
{
"name": "3",
"agentName": "sdfsf",
"address": "Ed Spencer",
"workMethod": "22",
"phone": "blue",
"mobilePhone": "sdfdsf",
"workLicenseId": "sdfsdf",
"workLicenseIssueDate": "2012-03-23",
"workLicenseInvalidateDate": "2015-03-23"
}]
}
}

2个回答

前台删还是后台删,前台就直接遍历,后台如果你没办法改变这个得到的过程
拿到result的位置p1,向后查找{,用变量存t{的个数,如果又有下一个{,t++
发现},就t--,如果t==0,记录位置为p2,那么就删掉从p1到p2就可以了
不知道明白没有。

有个想法可以试试:
将这个json字符串放入一个数组中(你的这个JSON放入数组只有3个元素),
遍历这个数组删掉第3个元素

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问