We are passing JSON request to a WCF service which comprises some additional prefixes like xy1, xy2 and “@” sign etc which makes it customized JSON. Our WCF service’s create order method process this customized JSON to create orders.
We want to pass standard JSON to WCF service instead of customized one. Is there any way to pass standard JSON to WCF service and then it converts back to customized JSON with minimum code changes.
NOTE: This is sample JSON but actual JSON file is long and comprises more details.
customized JSON is as following:
{
"xy1:createOrder": {
"@test:xy1": "http://www.testing.com/schema/order",
"@test:xy2": "http://www.testing.com/schema/customer",
"xy1:order": {
"@Date": "2022-12-27",
"@orderNo": "FirstOrder1"
},
"xy2:customer": {
"@Id": "1",
"xy2:title": "Mr",
"xy2:fName": "Alex",
"xy2:lName": "John",
"xy2:emailId": "[email protected]"
}
}
}
standard JSON is as following:
{
"createOrder": {
"order": {
"Date": "2022-12-27",
"orderNo": "FirstOrder1"
},
"customer": {
"Id": "1",
"title": "Mr",
"fName": "Alex",
"lName": "John",
"emailId": "[email protected]"
}
}
}
2
Answers
you can try this code
In addition to eliminating unnecessary parts of your code, try josn.net to customize your requirements.
An example of how to use it: