Get Only Url Value Of Filestack Json.stringify?
I'm using FileStack on my website, according to FileStack Docs I have this actually:
Solution 1:
You're almost there, are not you?
What about appending [0].url
to the object which is returned ?
I mean substituting result = JSON.stringify(Blobs, ['url']);
for result = JSON.stringify(Blobs, ['url'])[0].url
;
UPDATE
My first anwser is wrong because result
in
result = JSON.stringify(Blobs, ['url'])
returns '[{"url":"https://cdn.filepicker.io/api/file/--link1--"}]'
, which is a string since it comes from a stringify
ed variable. Thus, result[0]
returns its first character, which is "["
. Finaly result[0].url
or put differently, "[".url
is undefined. (and can hardly be so)
Replace this part:
function(Blobs){
console.log(JSON.stringify(Blobs));
var result = JSON.stringify(Blobs, ['url']);
$('#files').html(result);
}
by
function(Blobs){
$('#files').html(Blobs[0].url);
}
If one wants to get the desired information from a json, one must not stringify
it.
Update
Or if you want to display numerous urls, because of multiple files replace the latter method by
function(Blobs){
var displayedUrls = "";
for (i = 0; i < Blobs.length; i++) {
displayedUrls += Blobs[i].url + "<br>";
}
}
$('#files').html(displayedUrls);
Post a Comment for "Get Only Url Value Of Filestack Json.stringify?"