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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:58:08+00:00 2026-06-13T00:58:08+00:00

Although there are several threads on this topic.. please do not mark this as

  • 0

Although there are several threads on this topic.. please do not mark this as duplicate.

My pojo looks like this :

public class sample {


    public sample() {
        // TODO Auto-generated constructor stub
    }

    private String instructions;
    private String resource;
    private List<Map<String,String>> fields;
    private String taskid;

    private List<Map<String,String>> answer;

    public String getTaskid() {
        return taskid;
    }
    public void setTaskid(String taskid) {
        this.taskid = taskid;
    }
    public String getInstructions() {
        return instructions;
    }
    public void setInstructions(String instructions) {
        this.instructions = instructions;
    }
    public String getResource() {
        return resource;
    }
    public void setResource(String resource) {
        this.resource = resource;
    }
    public List<Map<String,String>> getFields() {
        return fields;
    }
    public void setFields(List<Map<String,String>> fields) {
        this.fields = fields;
    }
    public List<Map<String,String>> getAnswer() {
        return answer;
    }
    public void setAnswer(List<Map<String,String>> answer) {
        this.answer = answer;
    }



}

I am doing a httpget and the result is an array of Json objects I try to typecast it to sample but it gives an exception.

the deserialization snippet is as follows

sample[] temp = gsonObj.fromJson(response, sample[].class);

the exception i get is

java.lang.RuntimeException: Unable to invoke no-args constructor for class [sample;. Register an InstanceCreator with Gson for this type may fix this problem.
    at com.google.gson.MappedObjectConstructor.constructWithAllocators(MappedObjectConstructor.java:68)
    at com.google.gson.MappedObjectConstructor.construct(MappedObjectConstructor.java:52)
    at com.google.gson.JsonObjectDeserializationVisitor.constructTarget(JsonObjectDeserializationVisitor.java:42)
    at com.google.gson.JsonDeserializationVisitor.getTarget(JsonDeserializationVisitor.java:60)
    at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:104)
    at com.google.gson.JsonDeserializationContextDefault.fromJsonObject(JsonDeserializationContextDefault.java:76)
    at com.google.gson.JsonDeserializationContextDefault.deserialize(JsonDeserializationContextDefault.java:54)
    at com.google.gson.Gson.fromJson(Gson.java:551)
    at com.google.gson.Gson.fromJson(Gson.java:498)
    at com.google.gson.Gson.fromJson(Gson.java:467)
    at com.google.gson.Gson.fromJson(Gson.java:417)
    at com.google.gson.Gson.fromJson(Gson.java:389)
    at HTTPClientUtils.getResultsFromMobileWorks(HTTPClientUtils.java:327)

Can you please let me know where i am making the mistake ??

  • 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-13T00:58:09+00:00Added an answer on June 13, 2026 at 12:58 am

    Can’t reproduce. But here what works:

    public class Sample {
    
        public Sample(){}
        public int kk;
        public List<Map<String,String>> fields;
    
    
        public static void main(String[] args) {
            String s = "[{\"kk\":1, \"fields\":[{\"a\":\"a1\"}]}, {\"kk\":5}, {\"kk\":2}, {\"kk\":8}, {\"kk\":6, \"fields\":[{\"b\":\"b1\"}]}]";
            Sample[] r = new Gson().fromJson(s, Sample[].class);
            for(Sample t: r)
                System.out.println(">> " + t.kk + " " + t.fields);
        }
    
    }
    

    results:

    >> 1 [{a=a1}]
    >> 5 null
    >> 2 null
    >> 8 null
    >> 6 [{b=b1}]
    

    Sidenote:

    1. Capitalize your classes, always.
    2. post a sscce
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I couldn't find a duplicate for this question for Java, although there are a
Although there are a lot of jquery autocomplete code in this forum. However I
Although the question title appears a bit subjective I am sure there is not
Is there a leak in this C code? Although the answer is coming correct,
There is something I am trying to accomplish although I'm not really sure where
Although there are a lot of posts about .net config files, I believe that
Although there are some similar questions I’m having difficulties finding an answer on how
I am currently trying to create a content uploading system and although there are
I'm building a site using CodeIgniter that largely consists of static content (although there
Although appengine already is schema-less, there still need to define the entities that needed

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.