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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:42:49+00:00 2026-06-04T17:42:49+00:00

Quick questions about GSON, after reading the documentation. This is what I have with

  • 0

Quick questions about GSON, after reading the documentation. This is what I have with JSON:

var json = { 
     id: "person1", 
     name: "person 1", 
     data: {"email": "1@test.com"},
     children: [{
                    id: "person2",
                    name: "person 2",
                    data: {"email": "2@test.com"},
                    children: []
                },{
                    id: "person3",
                    name: "person 3",
                    data: {"email": "3@test.com"},
                    children: []
                }
                ] 
} 

1) Can I use GSON without using Class objects in Java? Can this be done easily using GSON and Java. Meaning I can do something like

GSON gson = new GSON();
gson.toJson("name", "person 1");

2) When I use this example:

            Gson gson = new Gson();
            Person p = new Contact(rs.getString("name"));
            gson.toJson(p);
            String json = gson.toString();
            System.out.println(json);

My Json output is not what I expected. That Person instance is a public class instance with just one property – name (for testing purposes). Why would I see essentially Factory, serializeNulls, etc in the output?

Thanks

  • 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-04T17:42:50+00:00Added an answer on June 4, 2026 at 5:42 pm

    Replace this:

    gson.toJson(p);
    String json = gson.toString();
    

    with this:

    String json = gson.toJson(p);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two quick questions about Ruby's String#crypt(salt) method: In the documentation it says
I have a few quick questions about the Microsoft Detours Library. I have used
2 quick questions: I have done my best to learn about normalization forms, but
Two quick questions if I may, is this how I should go about taking
I have a quick question about this PHP function here. What is the am
I have a few quick questions about the iPhone software development. I did some
People have asked similar questions about the efficiency of various data structures but none
Quick question about include/requre_once . I have some code that is common to a
just a quick question about the mvc JqueryUI framework, i have a _layout.cshtml page
I have three questions about three nested loops: for (int x=0; x<400; x++) {

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.