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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:17:28+00:00 2026-05-26T12:17:28+00:00

I need to somehow convert a single json string into multiple objects of a

  • 0

I need to somehow convert a single json string into multiple objects of a particular type using GSON.

I have the format of a single json string (below contains 2 but there may be 100s)

{domain : name1, geo: us} {domain : name2, country : uk}

Now I want to convert the above into my pojo instances that map to each part of the string. Suppose the POJO is called Website. Then I need to split up the json string to 2 Website objects.

I was thinking of splitting the json string using a tokenizer of some sort and then applying some json logic on each part. I’m assuming I would have to do this before applying any json to pojo conversion?

I cant seem to find a way to do this. Please advise.

thanks so much

  • 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-26T12:17:29+00:00Added an answer on May 26, 2026 at 12:17 pm

    To deserialize json to a java pojo, try json-lib, http://json-lib.sourceforge.net/. This is a good solution. Although I would use flexjson for serialization.

    String json = "{bool:true,integer:1,string:\"json\"}";  
    JSONObject jsonObject = JSONObject.fromObject( json );  
    BeanA bean = (BeanA) JSONObject.toBean( jsonObject, BeanA.class );  
    

    where BeanA is your POJO.

    If you have muliple objects, like you showed in your example then do the following

    String json = "{'data':[{'name':'Wallace'},{'name':'Grommit'}]}";
    JSONArray jsonArray = (JSONArray) net.sf.json.JSONSerializer.toJSON(json);
    for (int i = 0; i < jsonArray.size(); i++) {
       JSONObject jsonObject = (JSONObject) jsonArray.get(i);
       BeanA bean = (BeanA) JSONObject.toBean( jsonObject, BeanA.class );
       //do whatever you want with each object
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following string: 3.39112632978e+001 which I need to convert to float. WolframAlpha
I need to convert a string of numbers into a string of letters to
I need to generate multiple random values under SQL Server 2005 and somehow this
All my times are in UTC timezone now I need to somehow convert it
I have a velocity ivar defined as a CGPoint. I need to somehow extract
Possible Duplicate: how to copy char * into a string and vice-versa I have
I have a object that im serializing to a JSON object using JSON.Net. This
Is there any way to make TypeDescriptor.GetConverter.ConvertFromString convert to DateTime using a custom format
I am using Javas UUID and need to convert a UUID to a byte
I need to format an array from a list of values. Currently I have

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.