Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c#序列化/反序列化和反斜杠_C#_Json_Serialization - Fatal编程技术网

c#序列化/反序列化和反斜杠

c#序列化/反序列化和反斜杠,c#,json,serialization,C#,Json,Serialization,我正在尝试序列化/反序列化我的数据。但是,在结果的开头和结尾添加了 。反斜杠的符号比中间插入的要差。 例如,如中所示,结果是: 我试着把反斜杠换成另一个符号 我的模型: public partial class oyunlar { public oyunlar() { } public Nullable<int> oyun_id { get; set; } public string oyun_adi { get; set;

我正在尝试序列化/反序列化我的数据。但是,在结果的开头和结尾添加了<代码> 。反斜杠的符号比中间插入的要差。

例如,如中所示,结果是:

我试着把反斜杠换成另一个符号

我的模型:

public partial class oyunlar
{        
    public oyunlar()
    {

    }
    public Nullable<int> oyun_id { get; set; }
    public string oyun_adi { get; set; }
    public Nullable<System.DateTime> oyun_tarihi { get; set; }
    public int salon_id { get; set; }
    public int tur_id { get; set; }
    public string oyun_aciklama { get; set; }
    public string oyun_suresi { get; set; }
    public byte[] oyun_foto { get; set; }


    public virtual oyun_turu oyun_turu { get; set; }
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
    public virtual ICollection<oyuncular> oyunculars { get; set; }
    public virtual salonlar salonlar { get; set; }
}
公共部分类oyunlar
{        
公营房屋
{
}
公共可空的oyun_id{get;set;}
公共字符串oyun_adi{get;set;}
公共可空的oyun_tarihi{get;set;}
public int salon_id{get;set;}
公共int tur_id{get;set;}
公共字符串oyun_aciklama{get;set;}
公共字符串oyun_suresi{get;set;}
公共字节[]oyun_foto{get;set;}
公共虚拟oyun_turu oyun_turu{get;set;}
[System.Diagnostics.CodeAnalysis.SuppressMessage(“Microsoft.Usage”,“CA2227:CollectionPropertiesShouldBreadOnly”)]
公共虚拟ICollection{get;set;}
公共虚拟沙龙{get;set;}
}
我的控制器:

 public async Task<ActionResult> Index()
    {
        var jason = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
        jason.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects;
        JsonSerializerSettings jsSettings = new JsonSerializerSettings();
        jsSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
        jsSettings.PreserveReferencesHandling = PreserveReferencesHandling.All;
        jsSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
        var oyunlars = db.oyunlars.Include(o => o.oyun_turu).Include(o => o.salonlar);
        var converted = JsonConvert.SerializeObject(oyunlars, jsSettings);
        return Json(converted, JsonRequestBehavior.AllowGet);
    }

公共异步任务和。我如何解决它?

看起来像和的副本。如果您必须使用Json.NET返回
操作结果,请参阅。如果您需要使用ReferenceLoopHandling返回
操作结果
,该答案应该解释如何执行。哦,谢谢,我会尝试。@dbcLooks像和的副本一样另外。如果必须使用Json.NET返回
ActionResult
,请参阅。如果需要使用ReferenceLoopHandling返回
ActionResult
,该答案应该解释如何执行。哦,谢谢,我会尝试的。@dbc