lundi 2 mai 2016

Can MVC deserialize the json string which is having perl_script naming convention

We are working with the third party vendor who is passing following object as part of Form post

{
    "application": 123,
    "order_reference": "01234",
    "new_status": "initialize"
}

As this is not the standard naming convention in C#, i created following model.

public class Response
{
    [JsonProperty("application")]
    public string Application {get; set;}

    [JsonProperty("order_reference")]
    public string OrderReference {get; set;}

    [JsonProperty("new_status")]
    public string NewStatus {get; set;}
}

And i have below code in controller.

[HttpPost]
public Notify(Response response)
{
   // code.
}

The request is coming to the above method, but the object is not deserializing, I could see that, only application property is getting mapped.

Could any one please let me know, whether i can make it work with the model i have created or do i have to create the same model as the response is coming?

Aucun commentaire:

Enregistrer un commentaire