"workItemData": "{\"pendingAppointment\":{\"orderId\":\"4000061392\",\"shipmentId\":\"SI139193599\",\"stopId\":\"1-70285467558\",\"orderStatus\":\"In-transit\",\"shipmentExecutionStatus\":\"EXECUTION_PENDING\",\"shipmentCapabilityType\":\"CAP_INTMDL STND\",\"lineOfBusiness\":\"IM\",\"stopType\":\"D\",\"locationId\":\"2856142\",\"locationName\":\"AMAZON.COM INC FC LAS7\",\"appointmentActionTraceLog\":\"OrderId:4000061392 OrderStopToken:1-70285467558 StopType:D CapabilityType:CAP_INTMDL STND. Shipment:[SI139193599]EXECUTION_PENDING;LastRailLegShipment:[SI139193598]EXECUTION_PENDING;CrossTownShipment:[SI139193597]EXECUTION_PENDING;OriginDrayShipment:[SI139193595]EXECUTION_DEPARTED LAST STOP;PickUpApptConfirmed:true. Expected ground time less than threshold of -1 hours. CurrentTime=2022-11-04T23:25:57.743-07:00[US/Pacific] Expected GroundTime=2022-10-15T10:00-07:00.Hours \"openAtStartOfDay\":true,\"closeAtEndOfDay\":true,\"isWorkOn\":true},{\"activityName\":\"RECEIVING FREIGHT\",\"dayOfWeek\":\"SUNDAY\",\"startTime\":\"00:01:00\",\"endTime\":\"23:59:00\",\"openAllDay\":true,\"openAtStartOfDay\":true,\"closeAtEndOfDay\":true,\"isWorkOn\":true},{\"activityName\":\"LOADING FREIGHT\",\"dayOfWeek\":\"SUNDAY\",\"startTime\":\"00:01:00\",\"endTime\":\"23:59:00\",\"openAllDay\":true,\"openAtStartOfDay\":true,\"closeAtEndOfDay\":true,\"isWorkOn\":true}]}},\"UIResponse\":{ \"RequestedStartDTTM\":\"2022-10-02\",\" Override24HrsSuggestedDTTM\":\"null\",\"Stop Action\":\"Drop Loaded Trailer\",\"ExceptionRequested\":\"null\"}"
}
下面是我的JSON得到的响应
我想做,\"UIResponse\":{ \"RequestedStartDTTM\":\"2022-10-02\",\" Override24HrsSuggestedDTTM\":\"null\",\"Stop Action\":\"Drop Loaded Trailer\",\"ExceptionRequested\":\"null\"}"
在括号}]}}内,并使其看起来像
"workItemData": "{\"pendingAppointment\":{\"orderId\":\"4000061392\",\"shipmentId\":\"SI139193599\",\"stopId\":\"1-70285467558\",\"orderStatus\":\"In-transit\",\"shipmentExecutionStatus\":\"EXECUTION_PENDING\",\"shipmentCapabilityType\":\"CAP_INTMDL STND\",\"lineOfBusiness\":\"IM\",\"stopType\":\"D\",\"locationId\":\"2856142\",\"locationName\":\"AMAZON.COM INC FC LAS7\",\"appointmentActionTraceLog\":\"OrderId:4000061392 OrderStopToken:1-70285467558 StopType:D CapabilityType:CAP_INTMDL STND. Shipment:[SI139193599]EXECUTION_PENDING;LastRailLegShipment:[SI139193598]EXECUTION_PENDING;CrossTownShipment:[SI139193597]EXECUTION_PENDING;OriginDrayShipment:[SI139193595]EXECUTION_DEPARTED LAST STOP;PickUpApptConfirmed:true. Expected ground time less than threshold of -1 hours. CurrentTime=2022-11-04T23:25:57.743-07:00[US/Pacific] Expected GroundTime=2022-10-15T10:00-07:00.Hours \"openAtStartOfDay\":true,\"closeAtEndOfDay\":true,\"isWorkOn\":true},{\"activityName\":\"RECEIVING FREIGHT\",\"dayOfWeek\":\"SUNDAY\",\"startTime\":\"00:01:00\",\"endTime\":\"23:59:00\",\"openAllDay\":true,\"openAtStartOfDay\":true,\"closeAtEndOfDay\":true,\"isWorkOn\":true},{\"activityName\":\"LOADING FREIGHT\",\"dayOfWeek\":\"SUNDAY\",\"startTime\":\"00:01:00\",\"endTime\":\"23:59:00\",\"openAllDay\":true,\"openAtStartOfDay\":true,\"closeAtEndOfDay\":true,\"isWorkOn\":true,\"UIResponse\":{ \"RequestedStartDTTM\":\"2022-10-02\",\" Override24HrsSuggestedDTTM\":\"null\",\"Stop Action\":\"Drop Loaded Trailer\",\"ExceptionRequested\":\"null\"}}]}}"
}
我为上面的代码编写的是
var str=",\""+"UIResponse"+"\"" +":" +"{ "+"\""+"RequestedStartDTTM"+"\"" +":\""+this.form41.value.overReq + "\","
+"\""+" Override24HrsSuggestedDTTM"+"\"" +":\""+this.form41.value.oversug + "\","
+"\""+"Stop Action"+"\"" +":\""+this.form41.value.stopAction1 + "\","
+"\""+"ExceptionRequested"+"\"" +":\""+this.form41.value.excepReqs + "\"}" ;
let workData=this.users['workItemData'] + str;
workData.slice(0,workData.lastIndexOf("}"))+str + "}\"" ;
我哪里错了?
我为上面的代码编写的是
var str=",\""+"UIResponse"+"\"" +":" +"{ "+"\""+"RequestedStartDTTM"+"\"" +":\""+this.form41.value.overReq + "\","
+"\""+" Override24HrsSuggestedDTTM"+"\"" +":\""+this.form41.value.oversug + "\","
+"\""+"Stop Action"+"\"" +":\""+this.form41.value.stopAction1 + "\","
+"\""+"ExceptionRequested"+"\"" +":\""+this.form41.value.excepReqs + "\"}" ;
let workData=this.users['workItemData'] + str;
workData.slice(0,workData.lastIndexOf("}"))+str + "}\"" ;
1条答案
按热度按时间hwazgwia1#
我希望我理解正确...您想要一个JSON/String对象吗?您可以轻松地将JSON转换为字符串,然后再转换回来,如下所示:
因此,您“构建”响应的部分可以非常容易。
如果要合并两个JSON对象,可以按如下方式操作:
第二个参数会覆写jsonOne的特性。如果jsonOne中没有特性,则会建立该特性。范例的结果为:
{test: "Hello 2", oldProperty: "Hello old", newProperty: "Hello New"}
你好,弗洛