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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:31:59+00:00 2026-05-26T00:31:59+00:00

I am trying to deserialize the following string, I am somewhat new to java

  • 0

I am trying to deserialize the following string, I am somewhat new to java and I cannot get this to work for the life of me… I am only trying to decode two strings in the object for now. My JSON and Java classes below. I am getting the result variable ok.

{
   "result": "true",
   "recentlyMarkedTerritories": {
      "0": {
         "pk_activity": "471",
         "fk_activity_type": "100",
         "activity_content": "Hhhhh",
         "fk_user": "2",
         "activity_image": "2_QZe73f4t8s3R1317230457.jpg",
         "created": "1317244857",
         "activity_status": "1",
         "activity_location_lat": "43.515283",
         "activity_location_lon": "-79.880678",
         "fk_walk": null,
         "fk_event_location": "73",
         "user_point": "0",
         "public_image": "0",
         "fk_event_location_lat": "43.515273",
         "fk_event_location_lon": "-79.879989",
         "profile_image": "2_y9JlkI3CZDml1312492743.jpg",
         "user_gender": "1",
         "user_dob": "236073600",
         "user_nickname": "junoman",
         "isFriend": "false",
         "profile_image_thumb": "2_y9JlkI3CZDml1312492743_t.jpg",
         "activity_image_thumb": "2_QZe73f4t8s3R1317230457_t.jpg",
         "relationship_status_idx": "2",
         "isBlocked": "false"
      },
      "1": {
         "pk_activity": "469",
         "fk_activity_type": "100",
         "activity_content": "Jsjsjs",
         "fk_user": "1",
         "activity_image": null,
         "created": "1317244508",
         "activity_status": "1",
         "activity_location_lat": "43.515283",
         "activity_location_lon": "-79.880678",
         "fk_walk": null,
         "fk_event_location": "73",
         "user_point": "0",
         "public_image": "0",
         "fk_event_location_lat": "43.515273",
         "fk_event_location_lon": "-79.879989",
         "profile_image": "1_4Cpkofueqnrb1316895161.jpg",
         "user_gender": "1",
         "user_dob": "116841600",
         "user_nickname": "JoePennington",
         "isFriend": "false",
         "profile_image_thumb": "1_4Cpkofueqnrb1316895161_t.jpg",
         "activity_image_thumb": null,
         "relationship_status_idx": "1",
         "isBlocked": "false"
      },
      .....
   }
}

And my java class below

RecentActivity infoList = null;
Gson gson = new Gson();
infoList = gson.fromJson(JSONString, RecentActivity.class);

public class RecentActivity {
    String result;
    recentlyMarkedTerritories recentlyMarkedTerritories = null;

    public RecentActivity() {

    }

    public class recentlyMarkedTerritories {
        public Set<recentlyMarkedTerritories> pk_activity = new HashSet<recentlyMarkedTerritories>() ;

        public recentlyMarkedTerritories() {    }
    }
}

Please forgive my lack of description but I’m sure the code helps. The JSON is already used in other applications so changing it is not an option.. 🙁

Thanks!

  • 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-26T00:31:59+00:00Added an answer on May 26, 2026 at 12:31 am

    Here are some nice Tutorials for JSON that will help you out.

    GSON

    JSON

    JSON Example with source code

    UPDATED

    Try like this,

     try {
                JSONObject object = new JSONObject(jsonString);
                JSONObject myObject = object.getJSONObject("recentlyMarkedTerritories");
    
                for (int i = 0; i < object.length(); i++) {
                    JSONObject myObject2 = myObject.getJSONObject(Integer.toString(i));
                    System.out.println(myObject2.toString(2));  
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to deserialize a stream but I always get this error End
I get the following error when trying to deserialize an object in C#. Exception
I am trying to deserialize a JSON String like (extracted this bit to show
I'm trying to deserialize an xml structure that looks like this: <somecontainer> <key1>Value1</key1> <key1>Value2</key1>
Trying to get my css / C# functions to look like this: body {
I'm trying to deserialize the following XML document: <?xml version=1.0 encoding=utf-8 ?> <TestPrice> <Price>
I'm trying to deserialize the following XML output: <?xml version=1.0 encoding=ISO-8859-1?> <Foo> <Val>Data1</Val> </Foo>
I am trying to deserialize a JSON string that was serialized by JSON.Net 4.0
I am trying to import a site collection and I get the following error:
I'm trying to deserialize the following XML (excerpt): <NSArray> <Song id=23507 type=Song> <title>Waking The

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.