WCF method returning JSON vs returning DataContract object RRS feed

  • Question

  • User749309136 posted


    Say I have a WCF service with Data contract as 'Customer'

    Now I have a service method like

    public List<Customer> GetAllCustomers();

    OR I can have a service method like this:

    public stirng GetAllCustomers_JsonString(); --- this method will return a json string of list of 'Customer'

    Which one is better and why.


    Thursday, January 24, 2013 2:12 AM


  • User-425639139 posted

    Depends on situation JSON is lightwieght and will hold less memory where as a DataContract Object may be heavy. If you use JSON you will need to make sure it it require Serialization and DeSerialization and may consume some time.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 24, 2013 4:38 AM