Sitecore Swamp

Dive in the Sitecore Swamp

NAVIGATION - SEARCH

json2csharp

http://json2csharp.com/

[

   {
      "firstname":"Jeff",
      "lastname":"Wang",
      "boys":[
         {
            "firstname":"Daniel",
            "lastname":"Wang"
         },
         {
            "firstname":"Brandon",
            "lastname":"Wang"
         }
      ],
   }
]

=> 

public class Boy
{
    public string firstname { get; set; }
    public string lastname { get; set; }
}

public class RootObject
{
    public string firstname { get; set; }
    public string lastname { get; set; }
    public List<Boy> boys { get; set; }
}

RestSharp - a smarter RESTful service client

var request = new RestRequest("ShoppingBasket") { Method = Method.POSTRequestFormat = DataFormat.Json};
request.AddBody(basketLineItem);
var response = _client.Execute(request);
POST /api/ShoppingBasket HTTP/1.1
Accept: application/json, application/xml, text/json, text/x-json, text/javascript, text/xml
User-Agent: RestSharp/104.4.0.0
Content-Type: application/json
Host: 101.2.171.213:8100
Content-Length: 80
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

{"CustomerId":"123456","ProductId":0,"ProductName":0,"Quantity":0,"UnitPrice":0}