Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
i have the follwing

C#
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace Filsookms.Models
{


    public class cimages
    {
        public List<cimage> data { get; set; }
    }



    public class cimage
    {

        [ScaffoldColumn(false)]


        public string public_id { get; set; }

        public string format { get; set; }

        public int version { get; set; }

        public string resource_type { get; set; }

        public string type { get; set; }

        public System.DateTime created_at { get; set; }

        public int bytes { get; set; }

        public int width { get; set; }

        public int height { get; set; }

        public string url { get; set; }

        public string secure_url { get; set; }



    }
}




then


XML
Cloudinary cloudinary = new Cloudinary(account);

          ListResourcesResult lr = new ListResourcesResult();

          lr = cloudinary.ListResourcesByPrefix("adimg/15");


          Filsookms.Models.cimages imgs = JsonConvert.DeserializeObject<Filsookms.Models.cimages>(lr.JsonObj.ToString());

          foreach (var item in imgs.data)
          {
              Response.Write(item.url);
          }



imgs.data is allways null

????????
Posted
Comments
Kornfeld Eliyahu Peter 8-Feb-15 13:37pm    
From your code it is unclear why it should not...

1 solution

I don't know what is in output to variable lr, but if it is an array of Json objects, to convert you don't need .ToString() only give the List<type> and cast it. e.g:

C#
imgs = (cimages)JsonConvert.DeserializeObject(lr, typeof(cimages));


There is an article on this site about it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900