截取如下一个字符串
{
"code": "0000",
"message": "",
"data": {
"payRecordId": "1",
"payUrlOrData":"alipay_sdk=alipay-sdk-java-3.1.0&app_id=2016072900113812&biz_content=%7B%22body%22%3A%22%E9%87%91%E5%A4%A7%E5%B8%88%E6%94%AF%E4%BB%98%E5%AE%9DAPP%E6%94%AF%E4%BB%98%22%2C%22out_trade_no%22%3A%22****20%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%2C%22subject%22%3A%22%E9%87%91%E5%A4%A7%E5%B8%88%E6%94%AF%E4%BB%98%22%2C%22timeout_express%22%3A%2230m%22%2C%22total_amount%22%3A%225%22%7D&charset=UTF-8&format=json&method=alipay.trade.app.pay¬ify_url=http%3A%2F%2F192.168.153.116%3A19030%2Fpay%2FnotifyByAlipay&sign=sbY%2FKCVLNzz3sTTwXOVFhxDZ5U91elOwlvVKt4o0J6vZan9WBnkCNgPleyvtrchSF2hySqQYycAbE0fVCB3p7Uj0s%2BrB%2FKQUSfeDApsdjJjPEq4a%2FTTStoTJAK784l0q%2Bzc1Zn7pF1U7ALb6Jqv7AtSzZa17YkHFKtDmHr1c4GU%3D&sign_type=RSA2×tamp=2018-06-26+14%3A38%3A54&version=1.0"
},
"success": true
}
val str = data.payUrlOrData.split("&".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
for (item in str){ if (item.substring(0,6) == "app_id"){ val appId = item.substring(item.indexOf("="),item.length) Log.e("mls","appId的值>>>" + appId) } if (item.substring(0,10) == "alipay_sdk"){ val aliPaySdk = item.substring(item.indexOf("="),item.length) Log.e("mls","aliPaySdk的值>>>" + aliPaySdk) } if (item.substring(0,11) == "biz_content"){ val bizContent = item.substring(item.indexOf("="),item.length) Log.e("mls","biz_content的值>>>" + bizContent) } }