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 8599359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:22:53+00:00 2026-06-12T01:22:53+00:00

I have a Table for categories , which stores Hierarchical Data in the following

  • 0

I have a Table for categories , which stores Hierarchical Data in the following format

NodeID—>ParentID—>NodeName

I want to select categories in the following manner for which i need to return a JSON Object in a predefined format.

JSON FORMAT

"Option 1": {"Suboption":200},
"Option 2": {"Suboption 2": {"Subsub 1":201, "Subsub 2":202},
             "Suboption 3": {"Subsub 3":203, "Subsub 4":204, "Subsub 5":205}
            }

enter image description here

How do i return JSON in this format from a hierarchical database?? I mean how do i approach?? Kindly show me a direction.

NOTE:

Click Here to Checkout the (jQuery) Plugin I am using

  • 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-12T01:22:54+00:00Added an answer on June 12, 2026 at 1:22 am

    Provided you are in ASP.Net you can just iterate though it using the build in functions:

    System.Web.Script.Serialization.JavaScriptSerializer oSerializer = 
             new System.Web.Script.Serialization.JavaScriptSerializer();
    string sJSON = oSerializer.Serialize(oList);
    

    You can perform iterations using loops as well:

    var productsJObject = JObject.Parse(result.Content.ReadAsStringAsync().Result);
    
    foreach (var category in categories)
    {
        foreach (var category2 in category.Value)
        {
            foreach (var category3 in category2.Value)
            {
                var olist = new MyList { Id = version.SelectToken("id").ToString()
                          };
            }
        }
    }
    

    This can be ugly but usable if you have a defined set of levels, if you are performing an Nth dimensional transition it gets very complex very fast.

    You can look here for an idea:

    Java – Create JSON Object from Multiple Multidimensional Arrays

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

Sidebar

Related Questions

I have a Hierarchical Table for Categories in this form NodeID ParentID NodeName Following
I have a Categories table in which each category has a ParentId that can
I have a simple SQL table which defines a set of hierarchical categories and
I have a table:'Categories' which has two fields:Category_ID and Category. Data in Category_ID field
I have a table which stores categories and sub categories (self join) The table
I have a table which will contain various categories. The following is a minified
I have a categories table, which one of the fields serves as the foreign
I have a database table named Categories . I want to create a form
I have a table which stores a category mix for customers. The number of
I have 3 Tables: Regions Table which has 1500 Towns in it. Categories Table

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.