using System.ComponentModel.DataAnnotations;
namespace WebAPIDemo.Models
{
///
/// User Data
///
public class User
{
///
/// User Name
///
public string Name { get; set; }
///
/// User Age
///
public int Age { get; set; }
}
}
- 但所取得 JSON 格式為 Class member 的結果,因此第一字為大寫
using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json;
namespace WebAPIDemo.Models
{
///
/// User Data
///
public class User
{
///
/// User Name
///
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
///
/// User Age
///
[JsonProperty(PropertyName = "age")]
public int Age { get; set; }
}
}
- Psotmen: 輸出結果為 PropertyName 所命名的結果
- Ref:
- http://kevintsengtw.blogspot.tw/2016/02/aspnet-web-api-import-postman.html
沒有留言:
張貼留言