0

I'm using a request link to get the projects of a user. It returns many following:

{
id: 123456,
name: "Deneme 2",
published_on: 1427213730,
created_on: 1427213604,
modified_on: 1427213730,
url: "https://www.behance.net/gallery/123456/trial-2",
privacy: "public",
fields: [
"Film"
],
covers: {
115: "abc.com/xyz.jpg",
202: "abc.com/xyz.jpg",
230: "abc.com/xyz.jpg",
404: "abc.com/xyz.jpg"
}}

but covers and images arrays are problematic. Their names are numeric, and when I use Json.Net to deserialize them to a class that is identical to the fields on the returning JSON string, there occurs a problem because property names can't be numeric in C# classes, and when I change the names to alphanumerics (such as BehanceImg_138 instead of only 138), this time Json.Net can't match the field in the JSON string and BehanceImg_138 becomes null, although it's not null in JSON string. How can I overcome this problem?

Burak Karakuş
  • 1,368
  • 5
  • 20
  • 43
  • Providing a link that contains your personal API Key publicly is not considered good practice. Please remove the link and include the JSON in your question instead. – Delphi.Boy Apr 06 '15 at 14:57

1 Answers1

1

You can add a JsonProperty attribute to class properties. Like this:

public class BehanceData
{
  [JsonProperty("115")]
  public string _115 { get; set; }
}
Delphi.Boy
  • 1,199
  • 4
  • 17
  • 38