Solved

bulid json format

Posted on 2016-11-29
3
71 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:Seven price
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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:Seven price
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:Seven price
ID: 41906552
tks
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

627 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