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

  • Home
  • SEARCH
  • 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 4562878
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:16:41+00:00 2026-05-21T18:16:41+00:00

So I have a hierarchy of page objects and I am migrating from a

  • 0

So I have a hierarchy of page objects and I am migrating from a Postgres System over to MongoDB, but I still need to support some legacy client systems which expect data in flat RDBMS style format.

If I store it in Mongo I have something kinda like this:

{
    "id": "1",
    "title": "Top Page",
    "children": 
    [
        {
            "id": "2",
            "title": "Page Two",
            "children": 
            [
                {
                    "id": "3",
                    "title": "Page Three",
                    "children": []
                }
            ]
        }
        {
            "id": "4",
            "title": "Page Four",
            "children": []
        }
    ]
}

But I need to reformat it, so the client apps can read it. And they expect it in a format like this:

[
{
    "id": "1",
    "title": "Top Page",
    "parentid": "top"
}
{
    "id": "2",
    "title": "Page Two",
    "parentid": "1"
}
{
    "id": "3",
    "title": "Page Three",
    "parentid": "2"
}
{
    "id": "4",
    "title": "Page Four",
    "parentid": "1"
}
]

Is there an easy way to do this with Java or the MongoDB driver? or will I just have to iterate thru each of the objects and set the parentids manually? (some of these hierarchies are rather large).

  • 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-05-21T18:16:42+00:00Added an answer on May 21, 2026 at 6:16 pm

    There are 1000 ways to flatten a hierarchy, therefore I doubt there is an existing API to do that. Do it manually. It’s a simple recursive method, after all.

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

Sidebar

Related Questions

I have a hierarchy of objects define as follows: class Request { RequestType type
I have a hierarchy of objects that I would like to show using a
I have an hierarchy of classes that I fetch from database by LINQ to
I have a page that generates json data from several fields and I want
I have a hierarchy of classes: class Page { } class ChildPage1 extends Page
I have a page hierarchy as the following I want to execute a PageMethod
I have hierarchy which i need to bind to checkbox for parent and checkboxlist
in my activity I have login page (L), which leads to hierarchy of activites
I have say this hierarchy in ASP.NET: page user control 1 user control 2
Firstly, Sorry For lengthy question but I have to give some underlying information. We

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.