I have a Jarray of response and inside Jarray there is an array of Clients and based on the condition I need to select the object in Array Json is
JArray response = JArray.Parse(@"[
{
'ProviderTransactionID': '4c4c5b43-0dd6-490c-9a59-062e25c04019',
'IsSuccess': 'False',
'ErrorMessages': 'Some error',
'ClientInfo': [
{
'InternalID': '98367',
'UniqueID': '',
'ErrorMessages': 'ERROR:'
},
{
'InternalID': '98368',
'UniqueID': '',
'ErrorMessages': 'ERROR:'
}
]
}
]");
Run Code Online (Sandbox Code Playgroud)
For example, I need to select the ClientInfo Object where InternalID=98367
But
response.SelectToken("ClientInfo") returning null
response.SelectToken("ClientInfo") as …Run Code Online (Sandbox Code Playgroud) 我的 API 模型有一个类似于 JArray 类型的属性
public class MyModel
{
public JArray Credentials { get; set; }
public string Property1 {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
对于 Credentials Swagger 生成类似
"credentials": {
"type": "array",
"items": {
"$ref": "#/components/schemas/JToken"
},
"nullable": true
}
Run Code Online (Sandbox Code Playgroud)
模式就像
"JToken": {
"type": "array",
"items": {
"$ref": "#/components/schemas/JToken"
}
}
Run Code Online (Sandbox Code Playgroud)
这里JToken是自引用的,如何避免这种自引用呢?