Solved

bulid json format

Posted on 2016-11-29
3
45 Views
Last Modified: 2016-11-29
trying to get this format in c#

  public class ModelDto
    {
       

        public int clientID { get; set; }
        public int id { get; set; }
        public string name { get; set; }
        public string children { get; set; }



        public ModelDto()
        { }
}

Open in new window

[
    //    {
    //        id: 1,
    //        name: 'root1',
    //        children: [
    //            { id: 2, name: 'child1' },
    //            { id: 3, name: 'child2' }
    //        ]
    //    },
    //    {
    //        id: 4,
    //        name: 'root2',
    //        children: [
    //            { id: 5, name: 'child2.1' },
    //            {
    //                id: 6,
    //                name: 'child2.2',
    //                children: [
    //                    { id: 7, name: 'subsub' }
    //                ]
    //            }
    //        ]
    //    }
    //];

Open in new window

0
Comment
Question by:sevensnake77
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 41906024
check this page to do, almost, the job : http://json2csharp.com/


public class Child2
{
    public int id { get; set; }
    public string name { get; set; }
}

public class Child
{
    public int id { get; set; }
    public string name { get; set; }
    public List<Child2> children { get; set; }
}

public class RootObject
{
    public int id { get; set; }
    public string name { get; set; }
    public List<Child> children { get; set; }
}

Open in new window

1
 
LVL 9

Author Comment

by:sevensnake77
ID: 41906131
{
  "id": 0,
  "name": null
}

{
  "id": 0,
  "name": null,
  "children": null
}

{
  "id": 0,
  "name": null,
  "children": null
}

Open in new window

Understood. but objects i delcare no problem but the display still does not display what I have in my json format
0
 
LVL 9

Author Closing Comment

by:sevensnake77
ID: 41906552
tks
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

929 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now