0

How can I tell Asp.Net Mvc Model Binder to bind some values in the payload to some specific properties in the POCO Model?

For example I have a POCO Model which has 2 properties: FirstName and LastName, but the JSON object I'm getting has different names, like first_name_text and last_name_text. I've used a Model Binder to bind first_name_text to FirstName property in POCO etc.

I'm using Asp.net MVC 5.

Thank you

KBoek
  • 5,794
  • 5
  • 32
  • 49
Milad
  • 552
  • 1
  • 4
  • 20

1 Answers1

1

You could add data annotations over your POCO Model.

Here is better explanation: https://stackoverflow.com/a/15916121/9233618

public class TeamScore
{
[JsonProperty("first_name_text ")]
public string FirstName { get; set; }
[JsonProperty("last_name_text ")]
public string LastName { get; set; }
}
Matt
  • 1,245
  • 2
  • 17
  • 32