none
JSON string from WCF RRS feed

  • Question

  • I have one operation contract

    public string GetPlayers()
    {
        List<Person> players = new List<Person>();
        players.Add(new  Person { FirstName="Peyton", LastName="Manning", Age=35 } );
        players.Add(new  Person { FirstName="Drew", LastName="Brees", Age=31 } );
        players.Add(new  Person { FirstName="Brett", LastName="Favre", Age=58 } );

     System.Web.Script.Serialization.JavaScriptSerializer oSerializer =
             new System.Web.Script.Serialization.JavaScriptSerializer();
    string sJSON = oSerializer.Serialize(players);
    return sJSON;

    }


    This return json string as

    [{"Age":35,"FirstName":"Peyton","LastName":"Manning"}, 
     {"Age":31,"FirstName":"Drew","LastName":"Brees"}, 
     {"Age":58,"FirstName":"Brett","LastName":"Favre"}]

    IS THERE ANY WAY TO RETURN STRING AS

    {Players :
    [{"Age":35,"FirstName":"Peyton","LastName":"Manning"}, 
     {"Age":31,"FirstName":"Drew","LastName":"Brees"}, 
     {"Age":58,"FirstName":"Brett","LastName":"Favre"}] };

    Thursday, May 30, 2013 9:19 AM

Answers