Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9266889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:25:19+00:00 2026-06-18T14:25:19+00:00

I have MENUITEM and SCREEN entries defined in a root element MENUSTRUCT from a

  • 0

I have MENUITEM and SCREEN entries defined in a root element MENUSTRUCT from a json string.

The important thing here is that a MENUITEM can contain other MENUITEMs or SCREENs.

I want to parse the whole json string with JSON.NET where I should receive a tree with MENUITEMs that can contain a huge chain of nested MENUITEMs or SCREEN entries.

I snipped a lot of the nested structures from the following json string:

{
"MENUSTRUCT": {
"-text": "GUI.Menu.Root",
"-image": "GUI.Menu.Home",
"-mask": "GUI.Menu.Home.Mask",
"-color": "#E0E0FF",
"-menuid": "MENUTREE",
"MENUITEM": [
  {
    "-text": "GUI.Menu.Text.00000003",
    "-image": "GUI.Menu.Menu",
    "-mask": "GUI.Menu.Menu.Mask",
    "-color": "#C0C0FF",
    "-menuid": "Menu.ID.00000003",
    "SCREEN": [
      {
        "-id": "GUI.Dlg.StartupScreen",
        "-text": "GUI.Menu.Text.00000103",
        "-image": "GUI.Menu.Screen",
        "-mask": "GUI.Menu.Screen.Mask",
        "-menuid": "Menu.ID.00000103"
      },
      {
        "-id": "GUI.Dlg.Calls",
        "-text": "GUI.Menu.Text.Calls",
        "-image": "GUI.Menu.Screen",
        "-mask": "GUI.Menu.Screen.Mask",
        "-menuid": "Menu.ID.00000203"
      }
    ],
    "MENUITEM": [
      {
        "-text": "GUI.Menu.Text.00000603",
        "-image": "GUI.Menu.Menu",
        "-mask": "GUI.Menu.Menu.Mask",
        "-color": "#A0A0FF",
        "-menuid": "Menu.ID.00000603",
        "SCREEN": [
          {
            "-id": "GUI.Dlg.SpecialTrips",
            "-text": "GUI.Menu.Text.00010603",
            "-image": "GUI.Menu.Screen",
            "-mask": "GUI.Menu.Screen.Mask",
            "-menuid": "Menu.ID.00010603"
          },
          {
            "-id": "GUI.Dlg.SpecialTrips",
            "-text": "GUI.Menu.Text.00020603",
            "-image": "GUI.Menu.Screen",
            "-mask": "GUI.Menu.Screen.Mask",
            "-menuid": "Menu.ID.00020603"
          }
         ]  // end of screen
        }
     ]     // end of nested menuitem
  },
      /* snipped following menuitems */
]  // end of menuitem array
}
}

I tried to deserialize the whole thing with

JsonConvert.DeserializeObject<List<MenuItem>>(jsonString);

I have an object MenuItem which has a property of List<Screen> and one of List<MenuItem> but the whole thing doesn’t work out. I think the deserializer is not able to handle the nested MenuItems.

I also tried to parse the tree with JObject but I think this way you need to implement a lot of the parsing by yourself.

JObject obj = JObject.Parse(json);   
var menuItems = from m in obj["MENUSTRUCT"]["MENUITEM"].Children() select m;
List<MenuEntry> menues = this.LoadMenuStructure(menuItems);

Here I have to make sure that I am on the correct JToken but I have no idea if I’m handling with a MenuItem or a Screen.

Is there no other, easier, way to deserialize the the json string without nesting me through all the structures?

Thanks in advance for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T14:25:20+00:00Added an answer on June 18, 2026 at 2:25 pm

    Your original Script has errors in it and it has an additional blank , towards the bottom. I removed the C# // Comments tags as well this should work for you now

    {
        "MENUSTRUCT": {
            "-text": "GUI.Menu.Root",
            "-image": "GUI.Menu.Home",
            "-mask": "GUI.Menu.Home.Mask",
            "-color": "#E0E0FF",
            "-menuid": "MENUTREE",
            "MENUITEM": [
                {
                    "-text": "GUI.Menu.Text.00000003",
                    "-image": "GUI.Menu.Menu",
                    "-mask": "GUI.Menu.Menu.Mask",
                    "-color": "#C0C0FF",
                    "-menuid": "Menu.ID.00000003",
                    "SCREEN": [
                        {
                            "-id": "GUI.Dlg.StartupScreen",
                            "-text": "GUI.Menu.Text.00000103",
                            "-image": "GUI.Menu.Screen",
                            "-mask": "GUI.Menu.Screen.Mask",
                            "-menuid": "Menu.ID.00000103"
                        },
                        {
                            "-id": "GUI.Dlg.Calls",
                            "-text": "GUI.Menu.Text.Calls",
                            "-image": "GUI.Menu.Screen",
                            "-mask": "GUI.Menu.Screen.Mask",
                            "-menuid": "Menu.ID.00000203"
                        }
                    ],
                    "MENUITEM": [
                        {
                            "-text": "GUI.Menu.Text.00000603",
                            "-image": "GUI.Menu.Menu",
                            "-mask": "GUI.Menu.Menu.Mask",
                            "-color": "#A0A0FF",
                            "-menuid": "Menu.ID.00000603",
                            "SCREEN": [
                                {
                                    "-id": "GUI.Dlg.SpecialTrips",
                                    "-text": "GUI.Menu.Text.00010603",
                                    "-image": "GUI.Menu.Screen",
                                    "-mask": "GUI.Menu.Screen.Mask",
                                    "-menuid": "Menu.ID.00010603"
                                },
                                {
                                    "-id": "GUI.Dlg.SpecialTrips",
                                    "-text": "GUI.Menu.Text.00020603",
                                    "-image": "GUI.Menu.Screen",
                                    "-mask": "GUI.Menu.Screen.Mask",
                                    "-menuid": "Menu.ID.00020603"
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    }
    

    JSONLint The JSON Validator

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a XAML MenuItem DataBound ItemsSource that is working fine however there is
I have a Type MenuItem that has one-to-many relationship with itself through Children property.
I have a menu that looks something like this: <MenuItem x:Name=menu ItemsSource={Binding Items} Style={StaticResource
What i have here is a simple webview activity that when loaded it auto
I have an app which starts from a splash screen and then navigates to
I have 2 classes. One will be a basic instructions screen and on that
I have some XML that I am using as an Android text menu. Here
hey i have displayed a pop-up screen when i click on a menu item
I have a window with a MenuItem maddbound3 with the following ActionListener: maddbound3.addActionListener (
I have a Menu where each MenuItem in the hierarchy has its Command property

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.