package
xx;
import
com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject;
public
class
testJsonReplace {
public
static
void
main(String[] args) {
String query_jsOnstr=
"{\"timezone\":\"GMT+0\",\"action\":\"front_BRAND\",\"format\":\"true\",\"lan\":\"en_us\",\"column\":[\"day\",\"impressions\",\"clicks\",\"ctr\",\"brand_estimated_ecpm\",\"pay_out\"],\"dimension\":[\"day\"],\"filter\":{\"posid\":{\"op\":\"in\",\"value\":\"2454105\"}},\"start\":1528761600000,\"end\":1529452800000}"
;
JSONObject query = JSON.parseObject(query_jsonstr);
if
(query.getJSONObject(
"filter"
) !=
null
) {
JSONObject posJson =
new
JSONObject();
posJson.put(
"op"
,
"in"
);
posJson.put(
"value"
,
"2454117"
);
query.getJSONObject(
"filter"
).put(
"posid"
, posJson);
}
String posid = query.getJSONObject(
"filter"
).getJSONObject(
"posid"
).getString(
"value"
);
String newJsOnStr= query.toJSONString();
System.out.println(newJsonStr);
}
}