Hallo
We got the following two messages that is posted to API. but we need to be able to process both option in the same model.
I have been trying to do this by override on the Read and Write JasonConverter but it's either going to trigger on TSCREQ object or List<TSCREQ> it needs to be able to resolve both option in the same model
The models create for this as follow:
The issue is the model allows for the list of TSCREQ object, but doesn't resolve the single point issue. (Code below will do but this needs to be catered for both options.
We got the following two messages that is posted to API. but we need to be able to process both option in the same model.
I have been trying to do this by override on the Read and Write JasonConverter but it's either going to trigger on TSCREQ object or List<TSCREQ> it needs to be able to resolve both option in the same model
Object with single segment:
{
"WCSTSCORD0100": {
"HEAD": {
"Message_Id": "OUT21220118021156653304000109729",
"Date_Time": 20220118141157,
"Message_Type": "WCSTSCORD",
"Message_Version": 100,
"Sender_Id": "WMS_RP03",
"Recipient_Id": "658AICS1",
"TSCREQ":
{
"Automation_Id": "658AICS1",
"Site_Id": "ZAJNB02",
"Client_Id": "ZAGDE",
"New_Priority": 4700,
"TSCDET": {
"Key": 6861686
}
}
}
}
}
Object with array segment:
{
"WCSTSCORD0100": {
"HEAD": {
"Message_Id": "OUT21220118021156653304000109729",
"Date_Time": 20220118141157,
"Message_Type": "WCSTSCORD",
"Message_Version": 100,
"Sender_Id": "WMS_RP03",
"Recipient_Id": "658AICS1",
"TSCREQ": [
{
"Automation_Id": "658AICS1",
"Site_Id": "ZAJNB02",
"Client_Id": "ZAGDE",
"New_Priority": 4700,
"TSCDET": {
"Key": 6861686
}
},
{
"Automation_Id": "658AICS1",
"Site_Id": "ZAJNB02",
"Client_Id": "ZAGDE",
"New_Priority": 4700,
"TSCDET": {
"Key": 6861687
}
},
{
"Automation_Id": "658AICS1",
"Site_Id": "ZAJNB02",
"Client_Id": "ZAGDE",
"New_Priority": 4700,
"TSCDET": {
"Key": 6861688
}
}
]
}
}
}
The models create for this as follow:
Models been created:
public class DSVWCSTSCORD0100_Inbound
{
public int Id { get; set; }
public DSVWCSTSCORD0100? DSV_WCSTSCORD0100 { get; set; }
}
public class DSVWCSTSCORD0100
{
public int Id { get; set; }
public HEAD_WCSTSCORD? HEAD { get; set; }
}
public class HEAD_WCSTSCORD : HEAD
{
public List<TSCREQ>? TSCREQ { get; set; }
}
public class TSCDET
{
public int Id{ get; set; }
public int Key { get; set; }
}
public class TSCREQ
{
public int Id { get; set; }
public string? Automation_Id { get; set; }
public string? Site_Id { get; set; }
public string? Client_Id { get; set; }
public int New_Priority { get; set; }
public TSCDET? TSCDET { get; set; }
}
}
The issue is the model allows for the list of TSCREQ object, but doesn't resolve the single point issue. (Code below will do but this needs to be catered for both options.
Class that will cater for the single object:
public class HEAD_WCSTSCORD : HEAD
{
public TSCREQ? TSCREQ { get; set; }
}
public class TSCREQ
{
public int Id { get; set; }
public string? Automation_Id { get; set; }
public string? Site_Id { get; set; }
public string? Client_Id { get; set; }
public int New_Priority { get; set; }
public TSCDET? TSCDET { get; set; }
}
Last edited by a moderator: