"[{\\\"fromNumber\\\":\\\"0\\\",\\\"content\\\":\\\"停顿500毫秒\\\",\\\"createTime\\\":\\\"2023-12-08 16:49:04.000\\\"}]"转为JSON.parse()能够处理的数据
时间: 2023-12-10 08:35:52 浏览: 82
以下是将"[{\\\"fromNumber\\\":\\\"0\\\",\\\"content\\\":\\\"停顿500毫秒\\\",\\\"createTime\\\":\\\"2023-12-08 16:49:04.000\\\"}]"转为JSON.parse()能够处理的数据的方法:
```java
import java.time.LocalDateTime;import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import org.json.JSONArray;
public class Main {
public static void main(String[] args) {
String input = "[{\\\"fromNumber\\\":\\\"0\\\",\\\"content\\\":\\\"停顿500毫秒\\\",\\\"createTime\\\":\\\"2023-12-08 16:49:04.000\\\"}]";
String output = input.replace("\\", "");
JSONArray jsonArray = new JSONArray(output);
System.out.println(jsonArray.toString());
}
}
```
输出结果为:
```json
[{"fromNumber":"0","content":"停顿500毫秒","createTime":"2023-12-08 16:49:04.000"}]
```
阅读全文