Note that there are some explanatory texts on larger screens.

plurals
  1. POGenerics / JSON JavaScriptSerializer C#
    primarykey
    data
    text
    <p>I'm building a winForms app in NET3.5SP1 using VS2008Express. Am trying to deserialize an object using the System.Web.Script.Serialization library.</p> <p>The error is: Type 'jsonWinForm.Category' is not supported for deserialization of an array.</p> <p>Cheers!</p> <pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Web; using System.Net; using System.IO; using System.Web.Script.Serialization; namespace jsonWinForm { public class Category { public int categoryid; public string name; public int serverimageid; public DateTime dateuploaded; public bool enabled; } public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { using (WebClient client = new WebClient()) { //manipulate request headers (optional) client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); string targetUri = "http://www.davemateer.com/ig/genius/category.php"; //execute request and read response as string to console using (StreamReader reader = new StreamReader(client.OpenRead(targetUri))) { string s = reader.ReadToEnd(); textBox1.Text = s; Category cat = new Category(); JavaScriptSerializer serializer = new JavaScriptSerializer(); // this fails with a //Type 'jsonWinForm.Category' is not supported for deserialization of an array. serializer.Deserialize&lt;Category&gt;(s); } } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload