解码
Base64.getDecoder().decode()
加密
Base64.getENcoder().encode()
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
public Boolean test(){
User user = new User();
user.setAddress("潍坊");
byte[] bytes = Base64.getDecoder().decode(user.toString().getBytes(StandardCharsets.UTF_8));
String decode = new String(bytes, StandardCharsets.UTF_8);
String f = JSON.toJSONString(decode);
JSONObject jsonObject = JSON.parseObject(f);
System.out.println("方法执行");
return true;
}
JSON转化使用的alibaba fastjson包
依赖
com.alibaba fastjson2.0.3.graal



