Dee*_*mar 4 api rest asp.net-web-api postman
我在邮递员中发现了一个奇怪的问题。在下面的请求金额是整数字段。
{ "merchantId": 49, "amount": 020 }
Run Code Online (Sandbox Code Playgroud)
当我通过数量 020 而不是 20 时。在 API 控制器中,我收到数量 16。当我通过 0100 时,我收到 64。
如果我传入像“020”或“0100”这样的双引号。然后我得到 20 和 100。
下面是控制器方法和请求类:
[HttpPost]
public IHttpActionResult Post(XXXXXXXXCommand command)
{
IHttpActionResult result = null;
using (_logger.PushWeb())
{
_logger.Info("POST request to /transactions/debits/accountsetup", command);
try
{
}
catch (MerchantNotFoundException ex)
{
_logger.Error("XXXX", ex);
}
}
return result;
}
[DataContract(Name = "XXXXCommand")]
public class XXXXXXCommand : CommandBase
{
/// <summary>
/// Merchant ID
/// </summary>
[DataMember(Name = "merchantId", Order = 1)]
public int MerchantId { get; set; }
/// <summary>
/// Transaction amount
/// </summary>
[DataMember(Name = "amount", Order = 2)]
public int Amount { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
它看起来像邮递员错误。
Prefixing a number with 0 makes it interpreted as an octal number.
Octal number syntax uses a leading zero. If the digits after the 0 are outside the range 0 through 7, the number will be interpreted as a decimal number.
var n = 0755; // 493
var m = 0644; // 420
Run Code Online (Sandbox Code Playgroud)
For more information see this link.
| 归档时间: |
|
| 查看次数: |
5496 次 |
| 最近记录: |