Reputation: 1521
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 "".
Is there JSoup like libraries for JSON ?
Upvotes: 28
Views: 38763
Reputation: 511
Try Like This
Use Header "Accept:text/javascript"
String InboxJson=Jsoup.connect("https://www.fiverr.com/conversations/Json")
.timeout(1000000)
.header("Accept", "text/javascript")
.userAgent("Mozilla/5.0 (Windows NT 6.1; rv:40.0) Gecko/20100101 Firefox/40.0")
.get()
.body()
.text();
Upvotes: 7
Reputation: 621
You can fetch JSON or other data format using this:
// JSON example
String json = Jsoup.connect(url).ignoreContentType(true).execute().body();
Upvotes: 62
Reputation: 2943
You should use a JSON library to process JSON Data.
Here are some: Click
Upvotes: 0