解析值时遇到意外的字符:<。路径'',第0行,第0位。 [英] Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

查看:702
本文介绍了解析值时遇到意外的字符:<。路径'',第0行,第0位。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题出现在实时服务器上。在本地IIS中工作。



用于反序列化我在使用



var data = JsonConvert.DeserializeObject<数据集>(response.Content);



这是我的json:



{表: [{OrganisationID:1001,NAME:LORD MEHER INTER COLLEGE,Type:1,Code:HS0101,SiteUrl:http://school.com/HS0101/Home/登录,

IsOnline:false,OwnerName:MR NIGAM,OwnerContact:9858758510,OwnerEmail:TEST@gmail.com,地址: 631 / K-139,GAUTAM NAGAR,NOIDA,Pincode:201301,COUNTRY:INDIA,STATE:UTTAR PRADESH,CITY:NOIDA}}}



我尝试了什么:



i已从json中删除了所有空值。

This issue comes on live server. In local IIS its working.

for deserialize i am uing

var data = JsonConvert.DeserializeObject<dataset>(response.Content);

this is my json:

{"Table":[{"OrganisationID":1001,"NAME":"LORD MEHER INTER COLLEGE","Type":1,"Code":"HS0101","SiteUrl":"http://school.com/HS0101/Home/Login",
"IsOnline":false,"OwnerName":"MR NIGAM","OwnerContact":"9858758510","OwnerEmail":"TEST@gmail.com","Address":"631/K-139, GAUTAM NAGAR, NOIDA","Pincode":"201301","COUNTRY":"INDIA","STATE":"UTTAR PRADESH","CITY":"NOIDA"}]}

What I have tried:

i have removed all null values from json.

推荐答案

快速谷歌搜索显示您可能没有将JSON传递给反序列化对象方法。



c# - 解析值时遇到意外的字符 - Stack Overflow [ ^ ]



鉴于您没有提供太多的代码示例,我会说那个response.Content实际上不是一个字符串,而是你发出的地方。



你需要确保response.Content是一个字符串而不是一个HttpResponseMessage 。



另外,如果response.Content是我认为它被使用的方式。您可能需要将它与ReadAsString方法一起使用,以便将其转换为反序列化的字符串格式。
A quick google search shows that you are likely not passing JSON into the deserialize object method.

c# - Unexpected character encountered while parsing value - Stack Overflow[^]

Given you didn't provide much of a code sample, I'm going to say that response.Content isn't actually a string and is where you issue is coming in.

You need to ensure that response.Content is a string and not a HttpResponseMessage.

Also, if response.Content is how I think it is being used. You probably need to use it with the ReadAsString method in order to get it into a string format for Deserialization.


这篇关于解析值时遇到意外的字符:&lt;。路径'',第0行,第0位。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆