我正在尝试从一个JSON获取URL
{
"file_length":300,
"versions":[
{
"size":38267700,
"url":"https:\/\/sto006.sh-content.com\/v\/01\/00158\/v4h6zad7kdr1_n\/v4h6zad7kdr1_n.mp4?t=x7xUQpMLNKmr2glDAIN6YetW_hucsU9gzLOq6ifOuWw&s=1677397458&e=129600&f=790153&sp=300&i=0.0",
"name":"n"
}
],
"player_img":"https:\/\/sh-content.xyz\/v4h6zad7kdr1_xt.jpg"
}
我只想从这个json文件url中获取那个url:https://api.streamhide.com/api/file/direct_link?key=1208rmfu7uutkadgs5rx&file_code=v4h6zad7kdr1
我尝试了什么:
RequestQueue queue = Volley.newRequestQueue(MainActivity.this);
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, Url, null, response -> {
try {
String url = response.getString("result");
Log.d("name",url);
} catch (JSONException e) {
e.printStackTrace();
}
}, error -> {
Toast.makeText(MainActivity.this, "Fail to get data..", Toast.LENGTH_SHORT).show();
});
queue.add(jsonObjectRequest);
请帮助我执行以下操作“从json文件获取url对象““url”:“https://sto006.sh-content.com“
1条答案
按热度按时间snz8szmq1#
解决方案包括解析一位结果变量,如下所示: