Solved

bulid json format

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

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
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…

831 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