我有javascript对象数组:
objArray = [
{"date":"07/19/2017 12:00:00 AM","count":"1000","code":"K100"},
{"date":"07/21/2017 12:00:00 AM","count":"899","code":"C835"},
{"date":"07/23/2017 12:00:00 AM","count":"700","code":"C837"},
{"date":"07/23/2017 12:00:00 AM","count":"800","code":"K100"},
{"date":"07/23/2017 12:00:00 AM","count":"50","code":"C837"}
];
我希望关键日期的所有值都具有与下面相同的值
这是预期的输出:
newObjArray = [
{"date":"07/19/2017 12:00:00 AM","count":"1000","code":"K100"},
{"date":"07/21/2017 12:00:00 AM","count":"899","code":"C835"},
{"date":"07/23/2017 12:00:00 AM","count":"1550","code":["C837","K100","C837"]}
]
我尝试过的方式可以获得预期的输出。任何可以帮助我处理我以获得所需输出的人。
答案 0 :(得分:5)
for (LogEvent event : MyAppenderForTesting.logEvents) {
String message = event.getMessage().toString();
if (message.contains(search)) {
// do somethind
}
}