我有这个功能
[FunctionName("json")]
public static JsonResult json
(
[HttpTrigger(AuthorizationLevel.Anonymous, new string[] { "POST", "GET", "DELETE", "PATCH", "PUT" })]
HttpRequest req,
TraceWriter log
)
{
return new JsonResult(new
{
Nome = "TONY",
Metodo = req.Method.ToString()
});
}
问题是它正在返回
{"nome":"TONY","metodo":"GET"}
我希望它返回
{"Nome":"TONY","Metodo":"GET"}
在ASP.Net Core 2中,我使用了这个:
services.AddMvc()
.AddJsonOptions(options => options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver());
// Keep the Case as is
如何配置Azure功能以实现这种方式?
答案 0 :(得分:4)
asInstanceOf
答案 1 :(得分:0)
将JsonPropertyAttribute添加到属性中,并通过文件顶部的#r“ Newtonsoft.Json”包含Json.NET。
#r "Newtonsoft.Json"
using Newtonsoft.Json;
并装饰属性
[JsonProperty(PropertyName = "nome" )]
public string Nome { get; set; }
[JsonProperty(PropertyName = "metodo" )]
public string Metodo { get; set; }