WCF HTTP Post: How to bind Json data to C# Model -


i creating http post method existing wcf application. method take c# object argument:

[operationcontract] [webinvoke(method = "post", uritemplate = "updatedetails", bodystyle = webmessagebodystyle.bare, requestformat = webmessageformat.json, responseformat = webmessageformat.json)] public void updatedetails(myobject myobject) {    // logic }  public class myobject {    public string title { get; set; }    public string details { get; set; } } 

if json data has properties called 'title' , 'details', mapped argument. i'd handle scenarios when json properties changed. example, if sender decide change 'title' 'event_title', there way map 'event_title' 'title' field of myobject class? can done data annotations?

use [datacontract] , [datamember(name = "name_as_it_will_appear_in_json")]

[datacontract] public class myobject {    [datamember(name = "event_title")]    public string title { get; set; }     [datamember]    public string details { get; set; } } 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -