非必要不要用JSONObject作為對(duì)象遠(yuǎn)程傳輸
服務(wù)A調(diào)用服務(wù)B,參數(shù)用JSONObject對(duì)象傳輸
服務(wù)A中設(shè)值LocalDateTime類型
服務(wù)B中取值A(chǔ)rrayList類型
//A
JSONObject jsonObject = new JSONObject();
jsonObject.put("now",LocalDateTime.now());
//B
JSONArray jsonArray = jsonObject.getJSONArray("now");
for (int i = 0; i < 6 - localDateTime.size(); i++) {
// 秒沒(méi)0
localDateTime.add(0);
}
LocalDateTime ldt = LocalDateTime.of(localDateTime.getIntValue(0), localDateTime.getIntValue(1), localDateTime.getIntValue(2), localDateTime.getIntValue(3), localDateTime.getIntValue(4), localDateTime.getIntValue(5));
在取值的時(shí)候,如果正好秒為0,那JSONArray長(zhǎng)度為5,有越界問(wèn)題。