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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:49:20+00:00 2026-05-29T17:49:20+00:00

In android, I’m using model classes with methods to handle the data manipulation. My

  • 0

In android, I’m using model classes with methods to handle the data manipulation. My data is brought in from webservices as json. I’m contemplating the possibility of using JSONObjects to store the values of class level attributes. But, I don’t know of a way to use the JSONObj as the “holder” variable and create access methods. I don’t want to predetermine these methods, as jsonRepository should hold the values, not always known at design time

For example, I’d like to have:
public class User {
private JSONObject jsonAttributes;

public User(String json) { 
    this.jsonAttributes= new JSONObject(json);
}

[IMPLICIT attribute access methods]

public string Prop1() returns jsonAttributes.getString("prop1");
public string Prop1(String newProp1) returns jsonAttributes.putString("prop1",newProp1);

public string Prop2() returns jsonRepository.getString("id");
public string Prop2(String newProp2) returns jsonAttributes.putString("prop2",newProp2);
....

from outside this class then, I would access the attributes simply…

User myUser = new User(someValidJson);
String myString = myUser.Prop1

Misguided? If not, how does one manage implicit property setting/getting?

  • 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-29T17:49:25+00:00Added an answer on May 29, 2026 at 5:49 pm

    As was mentioned in the comment above, why not create your user class, with all of the relevant memeber variables, and simply parse your JSON data in order to populate the ionformation in your user class.

    There are a lot of ways you can do this, but I would consider using the builder pattern, as it is flexible, which could be useful if your JSON data changes in the future.

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

Sidebar

Related Questions

android how to Send a String of data from an android mobile to server
Android 2.1 update 1 Eclipse 3.5 I have a problem reading data from my
Android applications can specify intent-priority. How does android handle security situation such as following.
Android: I am using following code to insert image into album According to description
Android SDK Manager complains WARNING: Java not found in your path. Instead of using
android.text.format.DateFormat specifies that using the format string 'a' should yield 'a' or 'p' and
Android activities have a pair of methods onRetainNonConfigurationInstance()/getLastNonConfigurationInstance() for keeping objects expensive for load
Android - when getting images from Gallery, they are with wrong orientation. For example,
Android allows content of a URL to be displayed within an application using WebView
Android Asus tablet is acessing images from android mdpi drawable and also lgoptimusp509 is

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.