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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:51:08+00:00 2026-05-25T20:51:08+00:00

I have an android application that relies heavily on Json Web Services. so I

  • 0

I have an android application that relies heavily on Json Web Services.
so I have many requests and responses based on json format.
The basic idea is i have a request that get’s a bean object, for example HotelSearchData and the request knows how to convert that bean to json map\ object then it writes that JSONObject to the network (using http\https).

naturally I need to convert from and to json.
For the time being I’m doing it in a bad but fast way:

  1. get the object
  2. have a list of const in the form of KEY_XXXX where xxxx is the name of the key and the value is the string that will be the actual key in the json object.
  3. use the key like in the following example: base.put(KEY_FROM_DATE, hotelSearchData.getFromDate())
  4. for ArrayList\ arrays I use JSONArray naturally, each {} in json is a bean object as far as I’m concerned and I need to create a bean for it.

The problem is that this way, for future development is not so good (for the very least…)
Every new request requires me new beans that some of them may have the same information inside them causing information and code duplicity.

Every new request requires me to create new KEY finals copying sometimes from other request with similar keys – idiotic :-/

for the first item, except for optimizing what I’m about to do and dividing shared code beans to smaller items i can extend later on i can’t see any elegant solution.

But for the requests\response I thought of something but I’m not so sure how elegant it is…
I know Google have a different json library that uses reflection to serialize\deserialize JSONObjects. I thought of using annotations and reflection to do the serialization and deserialization, the annotations should help in the cases where the member name is NOT the same as the json key for the member’s value. also for ArrayList<?> that it’s type is not saved in byte code and so does not exist after compilation, so you can either specify basic type or full package name.

In this way once I create the bean with the help of some annotations (maybe python script \ant script to automate part of it ?) I can make beans that if tomorrow I move to xml or something else (binary) I can just create different serializer, deserializer and be done with it.

I hoped to hear your opinion on it, or some other solutions, get some inspiration, I’m really disappointed with my current code… 🙁

  • 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-25T20:51:09+00:00Added an answer on May 25, 2026 at 8:51 pm

    Have you actually tried gson? It will do the things you need, except the moving to XML/binary part, but you could probably abstract that in your code. Chances are that any XML serialization library might want to use different annotations, so it’s not going to be automatic.

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

Sidebar

Related Questions

I have a Web Service and an Android application that uses this web service.
I have developed an Android application that has 1 process and 2 services. But
I have an android application that gets data from the web such as an
I just completed an Android application that uses web services to connect to a
I have an Android application that connects to Facebook to request authorization of an
I want to build an notepad-style application on android that will have syntax highlighting.
I have an android application that starts an activity and is running well. I
I have an Android application that I've been working on, and it's implemented using
I have an Android application that is a TabHost with a WebView. I use
I have an Android application that makes use of TTS (Text to speech) API.

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.