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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:35:52+00:00 2026-06-06T07:35:52+00:00

Have a couple questions, using GSON. I have a feeling that GSON might not

  • 0

Have a couple questions, using GSON. I have a feeling that GSON might not be what I am looking for in terms of a library that will be able to give me a JSON object that I can use later.

I am reading data from a database to populate a json object that I will later use. The output of the json object should look similar to the json below, which involves parents and children. It forms a small tree based structure:

var json = { 
         id: "1", 
         name: "Joe Smith", 
         data: { 
         "email": "",
         "phone": "123-123-1233"},
         children: [{
                        id: "Tim Anderson",
                        name: "Tim Anderson",
                        data: { 
                             "email": "x@gmail.com",
                             "phone": "123-123-1233"
                        },
                        children: []
                    },{
                        id: "Christopher Johnson",
                        name: "Christopher Johnson",
                        data: {  
                             "email": "x@gmail.com",
                             "phone": "123-123-1233"
                        },
                        children: []
                    },{
                        id: "Kate Green",
                        name: "Kate Green",
                        data: {

                        },
                        children: [{
                            id: "Gary Jones",
                            name: "Gary Jones",
                            data: {},
                            children: []
                        }, {
                            id: "Melissa Brand",
                            name: "Melissa Brand",
                            data: {},
                            children: []
                        }]
                    }
                    ] 
    }

How do I create a GSON object, similar to the structure above, that I can serialize to JSON that has this type of hierarchy? I’ve tried using maps and other collections – but I am having difficulty getting the results I want. Hence why I ask if GSON is what I really want for a JSON serialization.

  • 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-06T07:35:54+00:00Added an answer on June 6, 2026 at 7:35 am

    Let me give you a hint

    make a Person and a Data class (POJO) like this

    Person
      String id
      String name
      Data data
      List<Person> children
    
    Data
      String email
      String phone
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a couple of questions. I have an algorithm that will generate a
I'm thinking of using the XStream library but I have a couple of questions/concerns.
I have couple questions regarding some C++ rules. Why am I able to call
I have a couple questions on playing videos in android. Currently I am using
Using SQL SERVER 2005, I have a couple of questions on Replication and referential
I have a couple of questions regarding using Google maps API, especially the Places
I have couple of questions here. I am using the following to write a
I have a couple of questions related to NCover: 1) I'm using MSBuild to
So I have a couple of questions about fork(): 1) I'm pretty sure that
I have a couple of questions about using databases with Jquery Mobile. When you

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.