Search code examples
iosjsonswiftjpeg

add picture to json?


This is a snipped of the json file i am using

 {
"id" : 12252013,
"name" : "Lassy",
"breed" : "Cocker Spaniel",
"photo_large" : 
"http://www.raywenderlich.com/downloads/puppies/spaniel.jpeg",
"price" : 39999
},

I want to use a local png like this but it is resulting in a blank picture.

{
"id" : 12252012,
"name" : "Penny",
"breed" : "Dachshund",
"photo_large" : "ready.jpg",
"cuddle_factor" : 5,
"price" : 29999
},

enter image description here

How can I get it to show like the picture below which uses a specifically hosted path for a jpeg?

enter image description here

I've tried using a image hosted on the web but haven't been able to find the right one quite yet.


Solution

  • In json objects you can provide the file path like that "photo_large" :"file:///XXXXXXXXXXXXXXXXXXXX/XXXX/XXX/filename" You can convert file path to URI and use it. Hope this help you.