使用Json.NET出现“文档的顶层无效。处理资源 URl 时出错。第 1 行,位置: 1
2010-05-13 22:27
603 查看
很惭愧昨天才知道json net这个东东。。。
下载地址:http://james.newtonking.com/projects/json-net.aspx
Serialization Example
Product product = new Product(); product.Name = "Apple"; product.Expiry = new DateTime(2008, 12, 28); product.Price = 3.99M; product.Sizes = new string[] { "Small", "Medium", "Large" }; string json = JsonConvert.SerializeObject(product); //{ // "Name": "Apple", // "Expiry": new Date(1230422400000), // "Price": 3.99, // "Sizes": [ // "Small", // "Medium", // "Large" // ] //} Product deserializedProduct = JsonConvert.DeserializeObject<Product>(json);
在输出是添加:
Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
Response.ContentType = "text/plain";
问题解决
相关文章推荐
- 名称以无效字符开头。处理资源 'http://localhost/' 时出错。第 1 行,位置: 2
- 名称以无效字符开头。处理资源 'http://localhost/发布了的/Default.aspx' 时出错。第 1 行,位置: 2
- 名称以无效字符开头。处理资源 'http://localhost/ws/Service.asmx' 时出错。第 1 行,位置: 2
- 名称以无效字符开头。处理资源 'http://localhost/' 时出错。第 1 行,位置: 2
- 名称以无效字符开头。处理资源 'http://localhost/ws/Service.asmx' 时出错。第 1 行,位置: 2
- 名称以无效字符开头。处理资源 'http://localhost/likong/' 时出错。第 1 行,位置: 2
- 名称以无效字符开头。处理资源 'http://localhost/likong/' 时出错。第 1 行,位置: 2
- 无法显示 XML 页.名称以无效字符开头。处理资源 'http://localhost/' 时出错。第 1 行,位置: 2
- 本内容中发现无效字符。处理资源 'file:///C:/Users/XDJ/Desktop/1111/press.xml' 时出错。第 5 行,位置: 11 <author>ƽ
- 名称以无效字符开头。处理资源 'http://localhost/departMent/default.aspx' 时出错。第 1 行,位
- 名称以无效字符开头。处理资源 'http://localhost/default.aspx' 时出错。第 1 行,位置: 2
- 在Nhibernate中使用Json.net中出现Self referencing loop的错误的处理
- Ext.form提交 ashx时 报“文档的顶层无效”的处理办法
- 关于Java.net.URL对象使用Proxy访问Internet资源
- 如何处理“使用 JSON JavaScriptSerializer 进行序列化或反序列化时出错”的问题
- 解决asp.net中:名称以无效字符开头.处理资源
- 名称以无效字符开头。处理资源 'http://localhost/' 时出错
- struts2之使用JSON插件实现Ajax(处理hibernate的POJO类时出现的异常)
- 使用队列和线程对现有asp.net动态页处理进行资源控制
- Android环境下使用net.sf.JSONObject问题出现BUG