【发布时间】:2020-02-28 07:25:32
【问题描述】:
我有一个 JSON 格式的 API 响应,如何在 c# 中将其转换为 XML 响应
我不知道将 JSON 转换为 XML 的脚本的位置
public static async Task<List<PointMaster>> ExecuteTest(string query)
{
string connStrResult = ConfigurationManager.ConnectionStrings["PostGresConnection"].ConnectionString;
NpgsqlConnection connection;
NpgsqlCommand command;
NpgsqlDataReader reader;
List<PointMaster> master = new List<PointMaster>();
connection = new NpgsqlConnection(connStrResult);
connection.Open();
command = new NpgsqlCommand(query, connection);
reader = command.ExecuteReader();
while (await reader.ReadAsync())
{
PointMaster point = new PointMaster
{
point_id = Convert.ToString(reader["point_id"]),
point_type = (string)reader["point_type"],
sp_geometry = (PostgisPoint)(reader["sp_geometry"]),
msid = Convert.ToInt32(reader["msid"]),
};
master.Add(point);
}
return master;
}
我希望将该响应更改为 XML
【问题讨论】:
-
看看这个问题stackoverflow.com/questions/18266952/… 以及它链接到的问题。我想你会找到你想要的。