A
A
Andrey2018-10-30 12:31:47
JavaScript
Andrey, 2018-10-30 12:31:47

How to parse json from json array?

When requesting the API:
127.0.0.1:6878/ace/manifest.m3u8?format=json&id=94... ,

a set of links is returned:
{
"response": {
"playback_url": " 127.0.0.1:6878/ace/r / 5410b27fc567c35c8547e3b69b141 ... ",
" stat_url ":" 127.0.0.1:6878/ace/stat/5410b27fc567c35c8547e3b69b ... ",
" command_url ":" 127.0.0.1:6878/ace/cmd/5410b27fc567c35c8547e3b69b1 ... ",
" event_url": " 127.0.0.1:6878/ace/event/5410b27fc567c35c8547e3b69... ",
},
"error":null
}

Now how to get the value of the "stat_url" array:

{ "response": { "status": "dl", "uploaded": 0, "speed_down": 516, "speed_up": 0, "downloaded": 14155776, "peers": 2, "total_progress": 0 } , "error": null }

On jquery I did this:

$.ajax
({ method: "GET",
url: " 127.0.0.1:6878/ace/manifest.m3u8 ",
dataType: "json",
data: {
format: "json",
id: "94c2fd8fb9bc8f2fc71a2cbe9d4b866f227a0209"},
success: function(data){

console.log(data.response.stat_url);

}});

returns: 127.0.0.1:6878/ace/stat/5410b27fc567c35c8547e3b69b... ,

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Edouard Faber, 2018-10-30
@torrentstreamru

Call $.ajax again in the `success` function, pass `data.response.stat_url` for the url

R
Rsa97, 2018-10-30
@Rsa97

Obviously, request data at the received URL.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question