none
WCF Function that accepts JSON Object contains three JSON Arrays? RRS feed

  • Question

  • how to design function that can decode all the values inside three jsonarrays of JSON object?
    Tuesday, April 28, 2015 8:24 AM

Answers

  • Hi Miskeen Ali Jatoi,

    I am not sure if I have misunderstood you, if you want to decode all the values inside the json object, first you need to define the DataContract something like the below code:

    [DataContract]
    public class Test1 { [DataMember] public string Test1Name{get;set;} [DataMember] public List<Test2> TestList2{get;set;} [DataMember] public List<Test3> TestList3{get;set;} [DataMember] public List<Test4> TestList4{get;set;} } [DataContract] public class Test2 { [DataMember] public string Test2Name{get;set;} } [DataContract] public class Test3 { [DataMember] public string Test3Name{get;set;} } [DataContract] public class Test4 { [DataMember] public string Test4Name{get;set;} }

    After that if your WCF Service is a SOAP services, first you need to convert the JSON object to a class object or collection object, then you can get all the value which you want inside the JSON object. If your WCF Service is a Rest Services, you can set the RequestFormat = WebMessageFormat.Json, in this way we can easy to get the correct result by using the Jquery, for more information, please try to refer to:
    #Post JSON data to WCF RESTful Service using jQuery:
    http://www.codeproject.com/Articles/722874/Post-JSON-data-to-WCF-RESTful-Service-using-jQuery .

    If I have misunderstood you, please feel free to let me know.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    Wednesday, April 29, 2015 7:13 AM
    Moderator