title: Exception while Parsing JSON with DataContractJsonSerializer
body: <p>I don't know if this is me or the JSON that I am getting. Anyhow I was reading this other article which I thought was relevant but no idea what the guys was talking about when he figured out what he needed to to <a href="https://stackoverflow.com/questions/6769532/more-json-c-sharp-issues">more json c# issues</a></p>
  
  <p>here is a sample of the JSON I am getting now</p>
  
  <pre><code>{
      "totalResult": 2,
      "merchants": {
          "1718167": {
              "merchantRank": "29",
              "merchantName": "bob the builders factory",
              "merchantSlogan": "if he can't fix it we can",
              "merchantBdesc": "",
              "merchantLogo": "pic1.gif",
              "merchantLink": "http:\/\/www.randomlink.com\/",
              "merchantAddress": "place
  street St
  area
  city
  1111",
              "merchantLat": "-15.9935425",
              "merchantLng": "58.0836955",
              "merchantGeoLevel": "st",
              "merchantDistance": "0.00",
              "merchantCategories": "builder",
              "merchantEmail": "",
              "merchantUrl": "http:\/\/www.randomlink.com\/",
              "merchantPhone": "0123456789",
              "merchantMobile": "",
              "merchantSrc": "AJF"
          },
          "113711": {
              "merchantRank": "229",
              "merchantName": "A A A Builders",
              "merchantSlogan": "",
              "merchantBdesc": "",
              "merchantLogo": "pic26.gif",
              "merchantLink": "http:\/\/www.randomlink.com\/",
              "merchantAddress": "",
              "merchantLat": "",
              "merchantLng": "",
              "merchantGeoLevel": "",
              "merchantDistance": "0.00",
              "merchantCategories": "Builder",
              "merchantEmail": "here@randomlink.com",
              "merchantUrl": "http:\/\/randomlink.com",
              "merchantPhone": "0123456789",
              "merchantMobile": "",
              "merchantSrc": "GHF"
          }
      }
  }
  </code></pre>
  
  <p>for the sake of sanity I have reduced the number of results, anyways, so I was attempting to build the data contracts for this and I came into an issue that I had previously, where some clever trickery got me the results that I need. However this time its different...</p>
  
  <p>Using the [DataContract] I can get the totalResult, however, to get merchants I keep getting errors... and I believe that because the "113711", and the "113711" are dynamic this causes a problem to create a data model. So I thought that perhaps a dictionary would solve this problem. However whenever I try it I get errors!!</p>
  
  <p>Here is what I tried to use:</p>
  
  <pre><code>[DataContract]
  public class result
  {
      [DataMember(Name = "totalResult")]
      public string totalResult { get; set; }
      [DataMember(Name = "merchants")]
      public Dictionary&lt;string, metchant_info&gt; merchants { get; set; }
  }
  [DataContract]
  public class metchant_info
  {
      [DataMember(Name = "merchantRank")]
      public string merchantRank;
      [DataMember(Name = "merchantName")]
      public string merchantName;
      [DataMember(Name = "merchantSlogan")]
      public string merchantSlogan;
      [DataMember(Name = "merchantBdesc")]
      public string merchantBdesc;
      [DataMember(Name = "merchantLogo")]
      public string merchantLogo;
      [DataMember(Name = "merchantLink")]
      public string merchantLink;
      [DataMember(Name = "merchantAddress")]
      public string merchantAddress;
      [DataMember(Name = "merchantLat")]
      public string merchantLat;
      [DataMember(Name = "merchantLng")]
      public string merchantLng;
      [DataMember(Name = "merchantGeoLevel")]
      public string merchantGeoLevel;
      [DataMember(Name = "merchantDistance")]
      public string merchantDistance;
      [DataMember(Name = "merchantCategories")]
      public string merchantCategories;
      [DataMember(Name = "merchantEmail")]
      public string merchantEmail;
      [DataMember(Name = "merchantUrl")]
      public string merchantUrl;
      [DataMember(Name = "merchantPhone")]
      public string merchantPhone;
      [DataMember(Name = "merchantMobile")]
      public string merchantMobile;
      [DataMember(Name = "merchantSrc")]
      public string merchantSrc;
  }
  </code></pre>
  
  <p>and here is the code behind...</p>
  
  <pre><code>            try
              {
                  Stream responseStream = e.Result;
                  DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(result));
                  result response = (result)ser.ReadObject(responseStream);
              }
              catch (Exception ex)
              {
                  return;
              }
  </code></pre>
  
  <p>The error I am getting currently is :</p>
  
  <pre><code>"Could not evaluate expression"
  </code></pre>
  
  <p>if you want the stack trace I will post it, but its a rather large amount of useless information... Also if you change the datamember Merchants to a string you will see the following error:</p>
  
  <pre><code>"System.Collections.Generic.Dictionary`2[System.String,System.Object]"
  </code></pre>
  
  <p>So... any thoughts?</p>