I want to convert my below nested request to Query String
var parameter = new RulesCommandServiceAppendRequest()
{
Chain = Chain.INPUT,
Data = new RuleInputModel()
{
Protocol = "tcp",
SourceIp = "2.2.2.2",
DestinationIp = "1.1.1.1",
SourcePort = "111",
DestinationPort = "222",
Jump = "DROP"
}
};
to something like below
Chain=INPUT&Data.DestinationIp=1.1.1.1&Data.DestinationPort=222&Data.Jump=DROP&Data.Protocol=tcp&Data.SourceIp=2.2.2.2&Data.SourcePort=111
WebSerializer workaround:
I try with the WebSerializer library with call WebSerializer.ToQueryString(parameter)
. I see the below output:
Chain=INPUT&Data=DestinationIp=1.1.1.1&DestinationPort=222&Jump=DROP&Protocol=tcp&SourceIp=2.2.2.2&SourcePort=111"
As you can see, the output is not as expected and my ASP.NET Web API .NET6 sample server does not accept this. (for more info you can see https://github.com/BSVN/IpTables.Api/pull/18)
Did you know another library for doing this or some trick to correct using WebSerializer?