通过post请求传入请求体为json返回为json
public static void main(String[] args) {
String q =base64格式的图片;
JSONObject s= JsonToObject("src",q);
System.out.println(s);
String url ="https://api.mathpix.com/v3/text";
try {
String res = send(url,s,"utf-8");
System.out.println(res);
} catch (ParseException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(q);
}
public static String send(String url, JSONObject jsonObject, String encoding) throws ParseException, IOException {
String body = "";
//创建httpclient对象
CloseableHttpClient client = HttpClients.createDefault();
//创建post方式请求对象
HttpPost httpPost = new HttpPost(url);
//装填参数
StringEntity s = new StringEntity(jsonObject.toString(), "utf-8");
s.setContentEncoding(new BasicHead

最低0.47元/天 解锁文章
1559

被折叠的 条评论
为什么被折叠?



