繁体   English   中英

C# Azure 函数嵌套 JSON 数据 POST

[英]C# Azure Function Nested JSON data POST

我想POST一个如下所示的JSON数据:

{
 "RequestID": "Req000002",
 "fullfillmenttFactor": 65,
 "ifFlexRequested": "True",
 "isBlind": "True",
 "loc": {
  "user001": 4,
  "user002": 7
 },
 "marketType": "fixedPrice",
 "maxPriceCtpEU": "null"
}

现在对于其他数据,我可以这样做:

[BsonElement ("RequestId"), JsonProperty(Required=Required.Always)] 
        public string RequestID { get; set; }

        [BsonElement("FullfillmentFactor"), JsonProperty(Required = Required.Always)]
        public int FullfillmentFactor { get; set; }

        [BsonElement("IfFlexRequested"), JsonProperty(Required = Required.Always)]
        public bool IfFlexRequested { get; set; }

但是如何处理Loc数据呢?

我可以做类似的事情:

public class LocationInfo: Document{
[BsonElement("LocInfo"), JsonProperty(Required = Required.Always)]
public int LocInfo { get; set; }
...
}

然后在Loc

[BsonElement("Loc"), JsonProperty(Required = Required.Always)]
public LocationInfo FullfillmentFactor { get; set; }

但是在这里我怎样才能传递多个这样的值:

"loc": {
  "user001": 4,
  "user002": 7
 }

例如,您可以将 loc 定义为 Dictionary

public Dictionary<string,int> loc { get; set; }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM