如何使用数组数据执行jsoup请求? Jsoup发布请求与数组数据并从PHP服务器获取json

I get json data with postman. Screenshot is the following. But I could't get json data with jsoup. How can I post a request with array data by using jsoup?

$link = mysqli_connect("localhost", "root", "pwd", "blockchain");
$cur_key ="";
$cur_key = $_POST['cur_key'];
// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}

$sql = "SELECT * FROM crypto where id IN('".implode("','",$cur_key)."')";
if($result = mysqli_query($link, $sql)){
    $encode = array();

    while($row = mysqli_fetch_assoc($result)) {
        $encode[] = $row;
    }

    echo json_encode($encode);

} else{
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
?>

postman result

My java code is like the following.

    try {

           Document doc = Jsoup.connect(_url).header("Content-Type","application/x-www-form-urlencoded;charset=UTF-8")
                    .data("cur_key[]", "bitcoin")
                    .data("cur_key[]", "ripple")
                    .method(Connection.Method.POST)
                    .header("Content-Type", "application/x-www-form-urlencoded")
                    .ignoreContentType(true)
                    .timeout(0).get();
        } catch (IOException e) {

            e.printStackTrace();

        }
dongluni0568
dongluni0568 你如何检查响应是否为空?您的回复是json格式。你有没有检查过如何处理jsoup中的json响应,例如:stackoverflow.com/questions/7133118/...
2 年多之前 回复
doumen6605
doumen6605 没有错误。但回应是空白的。
2 年多之前 回复
douci2022
douci2022 你得到什么错误?
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐