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);