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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:15:44+00:00 2026-06-14T11:15:44+00:00

I have this class that I persist by creating a JSON object based on

  • 0

I have this class that I persist by creating a JSON object based on its annotation:

@Entity(name = "user")
public class User { 
    @Id 
    private String id;
    @Column
    private String name;
    @Column
    private Integer age;
    public User() {}
public User(String id, String name, String age) {}
// ... code omitted
}

boolean ok = createEntity(new User("uid1", "eli", 25));

The method above will convert the User object into a Map respresenting a JSON object like:

map.put("ID", "uid1");
map.put("name", "eli");
map.put("age", 25);

This works fine. However I need to create a User object based on a response map containling values in similar form like the above, first I get the response from the server in form of JSON string:

{
    "id" : "uid2",
    "name" : "ben",
    "age" : 20
}

I mean, if I parse this JSON string into a map:

map.put("id", "uid2");
map.put("name", "ben");
map.put("age", 20);

How can I construct a User object filling the values from the map to the correct @Column field?

Update:

I know about Jackson library, but the idea here is that I need to work with annotations as I am building a library that needs classes to be annotated. I am just after the way to create object from json/map and assign the right values to the right field

  • 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-14T11:15:45+00:00Added an answer on June 14, 2026 at 11:15 am

    Use the Jackson library. It converts your objects to json without the need to annotate them.

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

Sidebar

Related Questions

I have this class: @Component @Scope(session) @Entity @Table(name = users) public class User {
I have class that looks like this: class A { public: class variables_map vm
I have a Handler class that looks like this: class Handler{ public $group; public
Assume I have a class that looks like this: class Sample { public string
I have a Java class that contains a list of another class. @Entity public
I have the following 2 entities: @Entity(name = Employee) @Table(name = EMPLOYEE) public class
I have an Entity class that looks like this: <?php namespace Entities; /** @Entity
I have an entity class with the following annotation on its primary key: @GeneratedValue(strategy
I have this class that have a function to load other classes and create
I have this class that contains vars for db connection; Imports Microsoft.VisualBasic Imports System.Data.SqlClient

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.