0
我在我的代码已经出现此错误:字符串转换为JSON对象C#
无效的对象传入,“:”或“}”的预期。 (14):{first_name = teste,last_name = teste,dia = 1,mes = 1,ano = 1890,mail = 1890, company =,ocupation = dsafad,pass = 123,country = Antigua,city = ffff ,user_type = 40}
我试图将此字符串转换为json,但我不能如何做到这一点。
var user_data = new {
first_name = register.first_name,
last_name = register.last_name,
dia = register.dia,
mes = register.mes,
ano = register.ano,
mail = register.ano,
company = register.company,
ocupation = register.ocupation,
pass = register.pass,
country = register.country,
city = register.city,
user_type = register.user_type
};
Session["JSON_OBJECT-USER-PREMIUM"] = user_data;
和我这样做对对方进行转换:
string new_user = Session["JSON_OBJECT-USER-PREMIUM"].ToString();
var json = new JavaScriptSerializer();
var data = json.Deserialize<Dictionary<string, string>[]>(new_user);
Response.Write(data);