在线求大神帮个忙!
{"resultmsg":"111","resultcode":"222","resultvalue":{"uask":[{"gid":"1","gtitle":"呼呼"...
{"resultmsg":"111","resultcode":"222","resultvalue":{"uask":[{"gid":"1","gtitle":"呼呼"},{"gid":"2","gtitle":"哈哈"}]}}
求问大神怎么把上下这两合并?
{"gid":"0","gtitle":"全部"}
非诚勿扰,小小白痴见笑
{"resultmsg":"111","resultcode":"222","resultvalue":{"uask":[{"gid":"0","gtitle":"全部"},{"gid":"1","gtitle":"呼呼"},{"gid":"2","gtitle":"哈哈"}]}}
合并后的效果 展开
求问大神怎么把上下这两合并?
{"gid":"0","gtitle":"全部"}
非诚勿扰,小小白痴见笑
{"resultmsg":"111","resultcode":"222","resultvalue":{"uask":[{"gid":"0","gtitle":"全部"},{"gid":"1","gtitle":"呼呼"},{"gid":"2","gtitle":"哈哈"}]}}
合并后的效果 展开
1个回答
展开全部
你没说用什么语言啊
更多追问追答
追问
抱歉,是php语言
追答
$json1 = '{"resultmsg":"111","resultcode":"222","resultvalue":{"uask":[{"gid":"1","gtitle":"呼呼"},{"gid":"2","gtitle":"哈哈"}]}}';
$json2 = '{"gid":"0","gtitle":"全部"}';
$arr1 = json_decode($json1, true);
$arr2 = json_decode($json2, true);
$arr2 = array($arr2);
$arr1['resultvalue']['uask'] = array_merge($arr2, $arr1['resultvalue']['uask']);
$arr1 = json_encode($arr1);
最后这个$arr1就是你的要格式,print_r($arr1)打出来看看
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询