Copyright: Copyright Rights Reserved https://blog.csdn.net/weixin_39921821/article/details/90520781
1. Obtain json simple string value corresponding to the key
It is provided to import a package json-lib-2.4.jar
code show as below:
import net.sf.json.JSONObject;
public class Test {
public static void main(String[] args) {
String jsonStr="{\"trans\":\"01\",\"fileId\":\"中心编号\",\"context\":\"文件流的base64字符串\"}";
JSONObject json = JSONObject.fromObject(jsonStr);
String trans=json.getString("trans");
String fileId=json.getString("fileId");
String context=json.getString("context");
System.out.println("["+trans+"]["+fileId+"]["+context+"]");
}
}
Renderings: