我正在尝试使用FlexJSON API转换此基于64个基于64的编码JSON字符串,并将接收到的JSON转换为POJO。
首先尝试块,将直接JSON作为字符串转换为成功的对象。该字符串是使用在线工具解码的。
现在第二次尝试块,尝试以类似的方式将基于64个基的字符串转换为对象,但在运行中转换了基于64个基的字符串,这是抛出异常 flexjson.jsonexception:预期a',''或']字符10
try {
AsyncResponseDO asyncResponseDO = new JSONDeserializer<AsyncResponseDO>().deserialize("{"relatesTo":"7_Sept2017_IF01"}", AsyncResponseDO.class);
System.out.println(asyncResponseDO.getRelatesTo());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
AsyncResponseDO asyncResponseDO = new JSONDeserializer<AsyncResponseDO>().deserialize(Base64.decodeBase64("eyJyZWxhdGVzVG8iOiI3X1NlcHQyMDE3X0lGMDEifQ==".getBytes()).toString(), AsyncResponseDO.class);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
pojo类:
public class AsyncResponseDO {
private String relatesTo;
public String getRelatesTo() {
return relatesTo;
}
public void setRelatesTo(String relatesTo) {
this.relatesTo = relatesTo;
}
}
新字符串(BASE64.DECODEBASE64(" EYJYZWXHDGVZVG8IOII3X1NLCHQYMDE3X0LGMDEIFQ ==="。
这将转换为适当的字符串。
我转介到https://www.mkyong.com/java/how-do-convert-byte-array-to-string-in-in-java/