Deserialize nested json arrays

1,687 views
Skip to first unread message

Frenchfaso

unread,
Apr 5, 2013, 11:17:35 AM4/5/13
to rest...@googlegroups.com
Hello all,
I have the following problem, can't manage to deserialize this json:

{
"items":
[
[
"string_1",
"string_2",
0,
null,
"string_3"
]
]
}

this is the c# class against I try to deserialize:

public class RootObject
{
public List<List>Object>> items { get; set; }
}

here the related RestSharp code:

var myItems = client.Execute<RootObject>(request).Data;

The myItems object is always null. The content type is "text/json" so the correct deserializer is fired, but I think the problem lies in the nested array..
any suggestions are highly appreciated!
Thanks

Mauricia Ragland

unread,
Apr 17, 2013, 8:44:37 AM4/17/13
to rest...@googlegroups.com
I'm having the same issue. What I noticed is that it's only occurring with a list of objects. In the following example otherIds populates:

    "categories": [
        {
            "items": [
                {
                    "id": 103,
                    "anotherId": 2,
                    "anotherList": [],
                    "price": {
                        "id": 0,
                        "priceId": 103,
                        "calories": 0,
                        "price": 0
                    },
                    "prices": [],
                    "active": false
                }
            ],
           otherId:[
                1, 2, 3
           ]
}]

Cristovão Morgado

unread,
Apr 17, 2013, 9:18:54 AM4/17/13
to RestSharp
Try to create your C# POCO with: http://json2csharp.com


--
You received this message because you are subscribed to the Google Groups "RestSharp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to restsharp+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Cristovao Morgado
@TheSaintr

Reply all
Reply to author
Forward
0 new messages