Adrian,
There's a pull request to address this issue:
https://github.com/restsharp/RestSharp/pull/236
Unfortunately, it was written right before the move from Json.Net to
SimpleJson. If you want to create a pull request that implements the
logic from that one, but for the new deserializer approach, I will be
happy to merge it in before we do the next release.
-pete
On Mon, Jul 02, 2012 at 02:00:43PM -0700, Adrian Inman wrote:
> I am trying to work with the Shopify API. A sample piece of JSON is
> shown at the bottom
>
> I have a POCO which looks like this:
>
> public class Product
> {
> public int id { get; set; }
> public string Title { get; set; }
> //public string BodyHtml { get; set; }
> public string Handle { get; set; }
> }
> public class Products : List<Product> { }
> When I call
> IRestResponse<Products> productsResponse =
> client.Execute<Products>(request);
> I get an exception as BuildList in JsonDeserializer gets upset on line
> 201 as it is coded to look for the [0] item in the array returned
> from type.GetGenericArguments() which actually returns a zero length
> array and so everything falls over.
> HELP! I'd dearly love some specific / up to date examples. I'm sure
> RestSharp is what I need, but not sure what I'm missing.
> Thanks in advance.
> {
> * products:
> [
> + {
> o body_html: "<p>WatchGuard XTM 22 1 year Security Software
> Suite</p> ",
> o created_at: "2012-05-31T23:33:56+01:00",
> o handle:
> "watchguard-xtm-22-1-year-security-software-suite-wg01771
> 4-wg017714",
> o id: 93303544,
> o product_type: "Firewall Security Licence",
> o published_at: "2012-05-31T23:33:56+01:00",
> o template_suffix: null,
> o title: "WatchGuard XTM 22 1 year Security Software Suite
> (WG017714)",
> o updated_at: "2012-06-24T18:18:04+01:00",
> o vendor: "WatchGuard",
> o tags: "",
> o variants:
> [
> # {
> @ compare_at_price: null,
> @ created_at: "2012-05-31T23:33:56+01:00",
> @ fulfillment_service: "manual",
> @ grams: 0,
> @ id: 218267520,
> @ inventory_management: null,
> @ inventory_policy: "deny",
> @ option1: "Default Title",
> @ option2: null,
> @ option3: null,
> @ position: 1,
> @ price: "219.93",
> @ product_id: 93303544,
> @ requires_shipping: false,
> @ sku: "WG017714",
> @ taxable: true,
> @ title: "Default Title",
> @ updated_at: "2012-06-01T21:15:01+01:00",
> @ inventory_quantity: 1
> }
> ],
> o images:
> [
> # {
> @ created_at: "2012-06-24T18:18:05+01:00",
> @ id: 189312170,
> @ position: 1,
> @ product_id: 93303544,
> @ updated_at: "2012-06-24T18:18:05+01:00",
> @ src:
> "[1]
http://cdn.shopify.com/s/files/1/0158/8830/
> products/watchguard_9260289.png?704"
> }
> ],
> o options:
> [
> # {
> @ name: "Title"
> }
> ]
> }
> + }
>
> References
>
> 1.
http://cdn.shopify.com/s/files/1/0158/8830/products/watchguard_9260289.png?704
--