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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:33:14+00:00 2026-06-02T18:33:14+00:00

I am facing an issue while I am trying to deserialize a JSON array

  • 0

I am facing an issue while I am trying to deserialize a JSON array of objects using the Gson library.

An example of the JSON array:

[
    {"ID":1,"Title":"Lion","Description":"bla bla","ImageURL":"http:\/\/localhost\/lion.jpg"},
    {"ID":1,"Title":"Tiger","Description":"bla bla","ImageURL":"http:\/\/localhost\/tiger.jpg"}
]

What do you think? What is the proper Java code to deserialize such a JSON response?

  • 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-02T18:33:16+00:00Added an answer on June 2, 2026 at 6:33 pm

    To deserialize a JSONArray you need to use TypeToken. You can read more about it from GSON user guide. Example code:

    @Test
    public void JSON() {
        Gson gson = new Gson();
        Type listType = new TypeToken<List<MyObject>>(){}.getType();
        // In this test code i just shove the JSON here as string.
        List<Asd> asd = gson.fromJson("[{'name':\"test1\"}, {'name':\"test2\"}]", listType);
    }
    

    If you have a JSONArray then you can use

    ...
    JSONArray jsonArray = ...
    gson.fromJson(jsonArray.toString(), listType);
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am facing some issues while serializing objects (I am using JBoss Drools, and
I am facing a class resolution issue while trying to make my architecture flexible.
I'm facing the same issue, while trying for cross-domain request. Situation is strange, my
I am facing an issue while trying to use the spring android framework. I
More precisely, I am facing this issue while trying to install https://github.com/barraponto/thacker-profile (commit 75c693581796eddae5fc39870dfcc2647e00c81b
I am facing a strange issue while compiling my own static library. My library
I am facing an issue while trying to install the requirements for my django
I am facing an issue while trying to reload rules dynamically. Starting with the
I am facing a strange issue while using javascript setTimeout function in IE8. I
I am using Appweb server (mini http server) and facing an issue while opening

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.