HOW TO GET IMAGE FROM JSON

Hai programmers, i'm a baby of xcode developer, and i really need a help. Below is one of my json data, that i have print in output, for the text i already got display into my screen, but now i'm trying to get the image from the server, and i don't know how to do it.


JSON :

"MoviePhotoL" : "\/Data\/UploadFile\/cnymv-01_1.jpg",

"MoviePhotoP" : "\/Data\/UploadFile\/cnymv-02_1.jpg"


XCODE:

let userImage = iP["MoviePhotoP"] as? String


cell.imageView.image = userImage ???


i know that String cannot be converted into UIImage, and i already try to convert it to NSData and convert the NSData to UIImage(data), but still not get the picture 😢.... can somebody please help me?? i really need some help

Accepted Answer

First of all, you need to clarify how you get that JSON (in fact, it is not a valid jSON). Do you get it from some REST API of a remote server? Or you get it from some framework for iOS?


Second, you need to know what's the values are meaning. /Data/UploadFile/cnymv-01_1.jpg or /Data/UploadFile/cnymv-02_1.jpg seems to be a file path of some system or it may be a relative path needed to retrieve the image from the server.


Anyway, as you know, String cannot be converted to UIImage. You may need to provide more info such as I noted above.

thanks for respond 😊...

i get it from server, which is here kozjin.sshitechss.com/api/KozjinGetHome, like you said the value is a relative path that retrieve from the server.. i already get the response from JSON, and for now, i only not get the image to display in my app, can you help me please?

You may need to call another API after you get the pass string in your JSON. (That may be a simple URL.)

Though, I cannot find any API references from the URL you provided. If you can show us the API reference page, we would be able to show something useful for you.

HOW TO GET IMAGE FROM JSON
 
 
Q