Ole*_* Sh 2 azure azure-logic-apps
我想根据以下类解析 json:
public class DerModel
{
public string Name { get; set; }
public string Email { get; set; }
}
public class DriverPositiveResultModel
{
public int DriverId { get; set; }
public string DriverName { get; set; }
public string DriverSSN { get; set; }
public string CarrierName { get; set; }
public DerModel DER { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
以及以下架构:
{
"properties": {
"CarrierName": {
"type": "string"
},
"DER": {
"properties": {
"Email": {
"type": "string"
},
"Name": {
"type": "string"
}
},
"type": "object"
},
"DriverId": {
"type": "integer"
},
"DriverName": {
"type": "string"
},
"DriverSSN": {
"type": "string"
}
},
"type": "object"
Run Code Online (Sandbox Code Playgroud)
}
但逻辑允许,DER 可以为空。如何在模式中设置它?
您需要指定它可以为空:
"type": ["object","null"]
Run Code Online (Sandbox Code Playgroud)
所以你的代码看起来像这样:
{
"properties": {
"CarrierName": {
"type": "string"
},
"DER": {
"properties": {
"Email": {
"type": "string"
},
"Name": {
"type": "string"
}
},
"type": ["object","null"]
},
"DriverId": {
"type": "integer"
},
"DriverName": {
"type": "string"
},
"DriverSSN": {
"type": "string"
}
},
"type": "object"
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
842 次 |
| 最近记录: |