mercredi 22 juin 2016

Json back slashes

I have a Web Api project and a controller receives a Json parameter like this

 public HttpResponseMessage QueryRead([System.Web.Http.ModelBinding.ModelBinder(typeof(WebApiDataSourceRequestModelBinder))] DataSourceRequest request, string queryparams, int qryId)

The string queryparams is actually a Json object that the client sends in the form

"{\"Supplier\":{\"name\":\"Supplier\",\"type\":\"PK\",\"textvalue\":\"[{\"Supplier_Key\":2,\"Supplier_Value\":\"Foxes Beverages \"}]\",\"value\":\"[2]\"}}"

This is a valid json object. The problem is that the string queryparams removes all backslashes and the string becomes

{"Supplier":{"name":"Supplier","type":"PK","textvalue":"[{"Supplier_Key":2,"Supplier_Value":"Foxes Beverages "}]","value":"[2]"}}

It ommits all backslashes and the later is not a valid json

Any ideas?




Aucun commentaire:

Enregistrer un commentaire