我将我的json有效负载保存在ex的typesafe conf文件中。 testdata.conf 第1步 { testRegForm:“ {\” formId \“:1,\” testRequestId \“:133,\” valid \“:true,\” formType \“:\” demo \“,\” identifier \“:null,}” }
* Now I want to replace the value of key ```"testRequestId\"```,i.e. 133 should be replaced by my code,So I wrote below code.
lang-java
String testDetail;
String custId = "1233";
for (Map.Entry < String,String > map: mapObj.entryset()) {
if (map.getKey().equals("ngoRegistrationForm")) {
testDetail = map.getvalue();
sb.append("\"" + map.getKey() + "\":" + testDetail.replaceFirst("ngoRequestId",custId) + ",");
}
String jsonString = sb.toString();
System.out.println("new payload 1 ::" + jsonString);
OUtput: "testRegForm": {
"formId": 1,"1233": 133,"valid": true,"formType": "NGO","identifier": null
}
但是它替换了密钥,有人可以帮忙如何替换密钥的值,即133应该被custId替换吗?