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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:20:47+00:00 2026-05-17T02:20:47+00:00

My java pojo looks like this public class myPersonTO{ String name; String surname; Map<String,

  • 0

My java pojo looks like this

public class myPersonTO{
  String name;
  String surname;
  Map<String, Double> categories;

}

I am using the gson library, however I an not sure what my json stringn, and the object it is created from should like; I am using json stringify, on a javascript object containing two strings and an array of objects, see pseudo code :

var json = [];
jsonObject = new Object();
jsonObject.name = "testname"
jsonObject.surname = "testsurname"
var categories = [];

for(index=0,index <10;index++){
    var category = new Object();
    category.key = getKey();
    category.value = index;
    categories.push(category);
}
jsonObject.categories = categories;
json.push(jsonObject);
json = JSON.stringify(json); //convert json object, then use in submit

and then in Java I am usign the following :

Type listType = new TypeToken<List<myPersonTO>>() {}.getType();
List<myPersonTO> myPersonTOList  = new Gson().fromJson(jsonString,listType);

Any help gratefully received. Cheers !

  • 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-17T02:20:48+00:00Added an answer on May 17, 2026 at 2:20 am

    Your question isn’t very clear, but I think the JSON verson of one of those objects would look like:

    {
      "name": "Bob",
      "surname": "Scum",
      "categories": {
        "whatever": 22.5,
        "balloons": 107.0023,
        "zebras": -10299.01
      }
    }
    

    edit — OK in response to the extensive changes in your question: your “categories” object should not be an array. It should be a plain object, as in my example. Well, at least that’s what I’d imagine it should be. I’d have to check this “gson” thing to make sure, but I’d be kind-of surprised to learn that it wants Java Map instances to be represented as arrays (surprised to the extent that I’d find another library).

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

Sidebar

Related Questions

Using GWT I have a Java class: public class Pojo { private String name;
I've got a simple java pojo which looks like this: class MyClass { public
com.vaadin.data.Property$ConversionException: java.lang.NoSuchMethodException: java.sql.Date.(java.lang.String) What is the fix for this... here is my POJO class
Consider a simple POJO Java Object: class MyObj { String a, b; Integer c;
I have a simple POJO like public class Employee { int level; int salary;
I have a DSL Java object, i.e. a POJO which returns this in setters
i have a table like this one: id | name | score mapped to
I am trying to mapp pojo class to mongodb using morphia-0.93-SNAPSHOT.jar but it is
Let's say I have a simple POJO class: public void Foo { public int
I'm trying to use plain old java objects(POJO)'s and regular class files where needed

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.