2

I have this simplified JSON array of objects being returned but the issue is the ID (13294 and 13350) is being treated as a type and is failing to deseialize.

Here is what I am using:

JsonConvert.DeserializeObject<List<JsonResultCustom>>(rawjson);

public class JsonResultCustom
{
    public string blurb { get; set; }
    public SplashImage splash_image { get; set; }
    public string title { get; set; }
    public string permalink { get; set; }
}

And the JSON:

{
   "13294": {
    "blurb": "Proin tellus enim, mollis id facilisis",
    "splash_image": {//CUSTOM OBJECT},
    "title": "MPC EXAMPLE with Video",
    "permalink": "https://www.test.com/"
   },
   "13350": {
     "blurb": "Soufflé cotton candy",
     "splash_image": {//CUSTOM OBJECT},
     "title": "MPC SAMPLE: Berry",
     "permalink": "https://www.test.com/blog/"
   }
 }
dbc
  • 104,963
  • 20
  • 228
  • 340
jordan
  • 21
  • 2
  • What makes you think those are `Id`'s? – Ňɏssa Pøngjǣrdenlarp May 03 '18 at 18:05
  • 3
    Deserialize to a `Dictionary` as shown in [How can I parse a JSON string that would cause illegal C# identifiers?](https://stackoverflow.com/a/24536564/3744182) and [Create a strongly typed c# object from json object with ID as the name](https://stackoverflow.com/a/34213724/3744182) – dbc May 03 '18 at 18:07
  • 1
    Your JSON is not valid *in terms of* deserializing to a list. You have an object (not an array) with properties that are objects. – Erik Philips May 03 '18 at 18:07

0 Answers0