<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=341183&amp;view=findpost&amp;p=2994339</guid>
        <pubDate>Sun, 25 Sep 2011 17:27:13 +0000</pubDate>
        <title>Десериализация JSON ответа</title>
        <link>https://forum.sources.ru/index.php?showtopic=341183&amp;view=findpost&amp;p=2994339</link>
        <description><![CDATA[arsenium: хм, да так работает, но тогда они получаются типа object...из него потом можно будет вытащить?]]></description>
        <author>arsenium</author>
        <category>.NET: Распределенные приложения</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=341183&amp;view=findpost&amp;p=2994330</guid>
        <pubDate>Sun, 25 Sep 2011 17:11:41 +0000</pubDate>
        <title>Десериализация JSON ответа</title>
        <link>https://forum.sources.ru/index.php?showtopic=341183&amp;view=findpost&amp;p=2994330</link>
        <description><![CDATA[UncleBob: [DataMember(Name = &quot;items&quot;)]<br>
        public List &lt;object&gt; TestItemsList { get; set; }<br>
<br>
вот так по идее сработает, а как типизировать такую коллекцию по-другому я хз]]></description>
        <author>UncleBob</author>
        <category>.NET: Распределенные приложения</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=341183&amp;view=findpost&amp;p=2994318</guid>
        <pubDate>Sun, 25 Sep 2011 16:47:43 +0000</pubDate>
        <title>Десериализация JSON ответа</title>
        <link>https://forum.sources.ru/index.php?showtopic=341183&amp;view=findpost&amp;p=2994318</link>
        <description><![CDATA[arsenium: хм, а можно ли обойти 3 во время десериализации? или нужно для нее новый класс описать?]]></description>
        <author>arsenium</author>
        <category>.NET: Распределенные приложения</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=341183&amp;view=findpost&amp;p=2994315</guid>
        <pubDate>Sun, 25 Sep 2011 16:39:25 +0000</pubDate>
        <title>Десериализация JSON ответа</title>
        <link>https://forum.sources.ru/index.php?showtopic=341183&amp;view=findpost&amp;p=2994315</link>
        <description><![CDATA[UncleBob: Объяснить что, почему код не работает? Так в items коллекция разнополых объектов получается, не укладывающаяся в List &lt;ItemsList&gt;]]></description>
        <author>UncleBob</author>
        <category>.NET: Распределенные приложения</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=341183&amp;view=findpost&amp;p=2994311</guid>
        <pubDate>Sun, 25 Sep 2011 16:35:25 +0000</pubDate>
        <title>Десериализация JSON ответа</title>
        <link>https://forum.sources.ru/index.php?showtopic=341183&amp;view=findpost&amp;p=2994311</link>
        <description><![CDATA[arsenium: Помогите разобраться с правильной десериализацией JSON ответа. К примеру имеем JSON ответ следующего вида:<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">{&quot;variant&quot;:&quot;otvet1&quot;,</div><div class="code_line">&nbsp;&quot;source&quot;:&quot;otvet2&quot;,</div><div class="code_line">&nbsp;&quot;items&quot;:[</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{&quot;list&quot;:&quot;512&quot;},</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{&quot;vist&quot;:&quot;315&quot;},</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{&quot;zist&quot;:&quot;561&quot;}]}</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script><br>
<br>
Для его десериализации код:<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">&nbsp;&nbsp; &nbsp;[DataContract]</div><div class="code_line">&nbsp;&nbsp; &nbsp;public partial class ItemsList</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;[DataMember(Name = &quot;list&quot;)]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public string lisType { get; set; }</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;[DataMember(Name = &quot;vist&quot;)]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public string vistType { get; set; }</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;[DataMember(Name = &quot;zist&quot;)]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public string zistType { get; set; }</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;[DataContract]</div><div class="code_line">&nbsp;&nbsp; &nbsp;public partial class SourceList</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;[DataMember(Name = &quot;variant&quot;)]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public string variantType { get; set; }</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;[DataMember(Name = &quot;source&quot;)]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public string vistType { get; set; }</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;[DataMember(Name = &quot;items&quot;)]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public List &#60;ItemsList&#62; TestItemsList { get; set; }</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;public class JsonStringSerializer</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public static T Deserialize&#60;T&#62;(string strData) where T : class</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(strData));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(T));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;T tRet = (T)ser.ReadObject(ms);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ms.Close();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return (tRet);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;private static SourceList SourceTempList;</div><div class="code_line">&nbsp;&nbsp; &nbsp;SourceTempList = JsonStringSerializer.Deserialize&#60;SourceList&#62;(e.Result); //в e.Result находится JSON ответ</div></ol></div></div></div></div><br>
<br>
И все работает как нужно, а вот если JSON ответ будет следующего вида:<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">{&quot;variant&quot;:&quot;otvet1&quot;,</div><div class="code_line">&nbsp;&quot;source&quot;:&quot;otvet2&quot;,</div><div class="code_line">&nbsp;&quot;items&quot;:[3,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{&quot;list&quot;:&quot;512&quot;},</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{&quot;vist&quot;:&quot;315&quot;},</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{&quot;zist&quot;:&quot;561&quot;}]}</div></ol></div></div></div></div><br>
<br>
т.е. после появления 3 в items, возникает проблема...и выше описанный код для десериализации не работает...<br>
был бы рад, если бы кто-нибудь смог мне объяснить...]]></description>
        <author>arsenium</author>
        <category>.NET: Распределенные приложения</category>
      </item>
	
      </channel>
      </rss>
	