【发布时间】:2020-04-04 12:08:23
【问题描述】:
我制作了一个 API,在详细说明实体框架之后,我发送一个用 Json 序列化的对象。
我的对象:
public class Package
{
public int Items { get; set; }
public string Code { get; set; }
public string Description { get; set; }
public double? Weight { get; set; }
public string Size { get; set; }
public string PackageType { get; set; }
}
问题在收到它(Xamarin 应用程序)后 Json 的第一个字母小写,但我想在完全相同的类中反序列化它,但它不能因为该类具有大写的属性(C# 标准)。 现在我正在使用一个可怕的“助手”类,它具有小写的属性来翻译它。
知道如何处理这个问题并直接用大写首字母发送 Json 吗?
编辑
我使用 ASP.NET Web API Core 和 Newtonsoft.Json
在 Xamarin 应用中,我使用 System.Text.Json
【问题讨论】:
-
你用的是asp.net web api core吗?
-
您使用的是 Newtonsoft.Json 还是 System.Text.Json?
-
对不起,我没有指定它...我使用 asp.net web api 核心,我在核心 API 中使用 Newtonsoft.Json,在 Xamarin 应用程序中使用 System.Text.Json
标签: c# json entity-framework asp.net-core asp.net-apicontroller