Solved

bulid json format

Posted on 2016-11-29
3
21 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
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…

743 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

10 Experts available now in Live!

Get 1:1 Help Now