Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create nested json with c#

Tags:

People also ask

Can JSON be nested?

Objects can be nested inside other objects. Each nested object must have a unique access path. The same field name can occur in nested objects in the same document.

Can you have nested arrays in JSON?

Attributes and event data can contain nested (JSON) values—arrays, objects, and arrays of objects.

What is JSON object in C?

Parsing JSON in C using microjson JavaScript Object Notation, or JSON, is a commonly used human-readable format for transmitting data objects as key-value pairs. Developed originally for server-browser communication, the use of JSON has since expanded into a universal data interchange format.


I am able to create a flat serialized JSON string pretty easily with c#

My issue is I want to create a nested string like this below

[ { 
    title: "Yes",
    id : "1",
    menu: [ { 
        title: "Maybe",
        id : "3",
        alert : "No",
        menu: [ {
            title: "Maybe Not",
            id : "8",
            alert : "No",
            menu: []
        } ]
    } ]
},
{
    title: "No",
    id : "2",
    menu: []
}]

Any help would be great