简体   繁体   中英

C# Azure Function Nested JSON data POST

I want to POST a JSON data which looks like this:

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

Now for the other data, I can do something like this:

[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; }

But what to do with the Loc data?

I can do something like:

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

and then in Loc :

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

But here how can I pass multiple values like this:

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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