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 ?
While great, Jsoup is a HTML parser, not a JSON parser, so it is useless in this context. If you ever attempt it, Jsoup will put the returned JSON implicitly in a <html><head> and so on. You don't want to have that. Gson is a JSON parser, so you definitely need it.
You can fetch JSON or other data format using this:
// JSON example String json = Jsoup.connect(url).ignoreContentType(true).execute().body();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With