Solved

bulid json format

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
We will take a look at the d3.js library for visualizations.  I will provide a walkthrough of a short bar graph example as well as introduce you to the d3.js API.  We also will explore links of other examples and further information regarding SVG's.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

685 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