JSoup:请求JSON响应 [英] JSoup: Requesting JSON response

查看:625
本文介绍了JSoup:请求JSON响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JSoup进行身份验证,然后连接到网站。某些URL具有JSON响应(因为该站点的一部分是在AJAX中)。 JSoup可以处理JSON响应吗?

I'm using JSoup to authenticate then connect to a website. Some URL have a JSON response (because part of the site is in AJAX). Can JSoup handle JSON response ?

Connection.Response doc = Jsoup.connect("...")
                               .data(...)
                               .cookie(...)
                               .header(...)
                               .method(Method.POST)
                               .execute();
String result = doc.body()

在我的情况下,正文是。

In my case body is "".


  • 是因为JSoup不知道如何处理JSON? (当然没有)

  • 或者因为我的请求中有错误?

是否有类似JSON的JSoup库?

Is there JSoup like libraries for JSON ?

推荐答案

您可以使用以下方式获取JSON或其他数据格式:

You can fetch JSON or other data format using this:

// JSON example
String json = Jsoup.connect(url).ignoreContentType(true).execute().body();

这篇关于JSoup:请求JSON响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆