我有一个具有以下示例结构的 json 文件
{
"contract": {
"marketScope": "AT",
"businessPartner": "GBM",
"salesChannelInformation": {
"salesChannelCode": "Integrated",
"salesChannel": "B-Partner information 1"
}
}
Run Code Online (Sandbox Code Playgroud)
给定一个jsonpath,我想修改一个特定的键值。
例如,将“contract.salesChannelInformation.salesChannelCode”更改为值“Integrated-Test”
目前我有以下代码:
public void setProperty(String fileString,String path, String value) {
if(JsonPath.given(fileString).get(path) == null){
Assert.fail("Path does not exist on json file");
}else {
try {
JSONParser jsonParser = new JSONParser();
JSONObject jsonObject = (JSONObject) jsonParser.parse(fileString);
System.out.println(jsonObject);
String[] tokens = path.split("\\.");
for (String token : tokens) {
System.out.println(token);
// Iterate the JsonObject, reach the key and modify the value
}
} …
Run Code Online (Sandbox Code Playgroud) 我正在用 Python 制作一个 API,它给我抛出了这样的东西。我已经尝试过 BeautifulSoup 并且它不接受它(既不是字节也不是转换为字符串)。我能做什么?
b'[{"cc_emails":["ccc@yyy.com"],"fwd_emails":[],"reply_cc_emails":["ccc@yyy.com"],"fr_escalated":false,"spam":false,"email_config_id":13000000444,"group_id":5000250803,"priority":1,"requester_id":5011075567,"responder_id":null,"source":1,"company_id":13000000455,"status":2,"subject":"[URGENT] - PNR TEAM -4 - XXXXXX","to_emails":["ccc@yyy.com"],"product_id":5000007514,"id":143266,"type":"Communication Partenaire","due_by":"2016-07-01T09:34:05Z","fr_due_by":"2016-06-30T21:34:05Z","is_escalated":false,"description":"<div>PNR xxxxxx HAS TO BE TICKETED ON 30Jun</div>","description_text":"PNR xxxxxE HAS TO BE TICKETED ON 30Jun","custom_fields":{"qualification_n2":"Partenaires","catgorie_produit":"Cie A\xc3\xa9rienne","qualification":"Gestion d\xc3\xa9placement","gestion_sc_htels":null,"client":"VVVVVVV","supplier_ticket":null,"hidden_fieldagentsignature":"Nous vous rappelons que pour toute demande vous pouvez nous contacter par t\xc3\xa9l\xc3\xa9phone au ou par email \xc3\xa0 ccc@mmm.com","hidden_fieldequipeddie":null,"team":"Team 3"},
"created_at":"2016-06-30T09:34:05Z","updated_at":"2016-06-30T09:34:07Z"},{"cc_emails":["ddd@wwww.com"],"fwd_emails":[],"reply_cc_emails":["ccc@3lll.com"],"fr_escalated":false,"spam":false,"email_config_id":13000000528,"group_id":5000250803,"priority":1,"requester_id":5011075567,"responder_id":null,"source":1,"company_id":13000000455,"status":2,"subject":"[URGENT] - PNR TEAM -4 - X6D2O2","to_emails":["ppp@3iiii.com"],"product_id":5000007514,"id":143265,"type":"Communication Partenaire","due_by":"2016-07-01T09:33:59Z","fr_due_by":"2016-06-30T21:33:59Z","is_escalated":false,"description":"<div>PNR XXXXX HAS TO BE TICKETED ON 30Jun</div>","description_text":"PNR XXXXXX HAS TO BE TICKETED ON 30Jun","custom_fields":{"qualification_n2":"Partenaires","catgorie_produit":"Cie A\xc3\xa9rienne","qualification":"Gestion d\xc3\xa9placement","gestion_sc_htels":null,"client":"PWC","supplier_ticket":null,"hidden_fieldagentsignature":"Nous vous rappelons que pour toute demande vous …
Run Code Online (Sandbox Code Playgroud)