[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

JSON.NET Deserialisation not able to retrieve some data

Posted on 2014-03-29
1
Medium Priority
?
322 Views
Last Modified: 2014-03-29
Hi all,

I have some Json which is successfully serialised using the following...
MyObj.Root deserializedMe= JsonConvert.DeserializeObject<MyObj.Root>(json);

Open in new window


It works very well until I get to the place where there is a further level without any title/name for the fields. Soemthing like the following.

MYGROUP":{"123":"HELPDESK"}

Open in new window


So MYGROUP can have as many items as possible. So I need some sort of list object with two variables. I keep getting a big JSON error and wondered if any someone could point me in the right direction.

So I have this...
 
public class MyObj
    {    
public class Root
        {
            public List<MYGROUP> MyGroups{ get; set; }
public class MYGROUP
        {
            string groupId { get; set; }
            public string name { get; set; }

        }}}

Open in new window


Its a toughy, so close to finally resolving all of this. Thanks in advance for any advice.
0
Comment
Question by:meetsys
1 Comment
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 1000 total points
ID: 39963782
the best trick I can give you is to serialize an instantiated and filled object with your classes and look at the generated string.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Six Sigma Control Plans
Introduction to Processes

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question