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

The Archive Base Latest Questions

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

I have search for many similar questions Expected BEGIN_OBJECT but was STRING but nothing

  • 0

I have search for many similar questions “Expected BEGIN_OBJECT but was STRING” but nothing work for me.
Here is my json string:

{
"result": "true",
"data": [{
    "from": {
        "user_id": "user1",
        "name": "user1",
        "avatar": "http://zzzzzz.jpg"
    },
    "request_id": "user1:user2"
},
{
    "from": "null",
    "request_id": "user1:user3"
}]
}

This is my mapping entities:

  public class GetFriendResponse {
    public boolean result;
    public List<FriendRequest> data;
  } 

  public class FriendRequest {
     public String request_id;
     public UserInfo from;
  }

  public class UserInfo {
    public String user_id;
    public String name;
    public String avatar;
 }

And I parse json like this:

 Gson gson = new Gson();
 GetFriendResponse  response = gson.fromJson(jsonString,GetFriendResponse.class);

I have check and see the problem is when the result contains "from": "null", it give an error.
Is there any idea?

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

    You should make the webservice return null or {}, not “null”.

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

Sidebar

Related Questions

I have seen many somewhat similar questions, but nothing quite what I'm looking for.
There are many questions about this PersistenceException, but I have not seen some, where
Similar questions to this are asked periodically, but many of these answers are outdated.
I have a scenario where I need to search from many binary files (using
I have a binary search loop which gets hit many times in the execution
I have search through the web to figure this out but no luck. I
I have search strings, similar to the one bellow: energy food olympics 2010 Terrorism
What is this about I notice many many apps I use have a similar
I have very similar multithreaded code elsewhere in my codebase that works fine, but
I have been googling, a lot, and found quiet many similar issues around 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.