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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:41:35+00:00 2026-06-14T02:41:35+00:00

I am using the following code to contain this Json public class RequestsDTO {

  • 0

I am using the following code to contain this Json

public class RequestsDTO
{
    @SerializedName ("requests")
    public Requests requestsContainer;

    public  class Requests 
    {
        @SerializedName ("request")
        public List<Request> requests;      
    }

    public class Request
    {

        @SerializedName ("amount")
        public Amount amount;

        @SerializedName ("id")
        public int requestId;

        @SerializedName ("status")
        public Status status;

        @SerializedName ("created")
        public String  created;
        @SerializedName ("start")
        public String start;

        @SerializedName ("notes")
        public Notes notes;

        @SerializedName ("type")
        public Type type;

        @SerializedName ("employee")
        public Employee employee;

        @SerializedName ("end")
        public String end;
    }

    public class Amount
    {

        @SerializedName ("content")
        public int time;
        @SerializedName ("unit")
        public String unit;
    }
    public  class Status
    {

        @SerializedName ("content")
        public String currentStatus;
        @SerializedName ("lastChanged")
        public String lastChangedDate;
        @SerializedName ("lastChangedByUserId")
        public int lastChangedByUserId;
    }
    public  class Notes
    {
        @SerializedName ("note")
        public List<Note> note;
    }
    public  class Note
    {
        @SerializedName ("content")
        public String content;
        @SerializedName ("from")
        public String from;
    }
    public  class Type
    {
        @SerializedName ("content")
        public String content;
        @SerializedName ("id")
        public int id;
    }
    public  class Employee
    {
        @SerializedName ("content")
        public String content;
        @SerializedName ("id")
        public int id;
    }
}

and the json:

 {"requests": {"request": [
     {
         "amount": {
             "content": 2,
             "unit": "hours"
         },
         "id": 246,
         "status": {
             "content": "superceded",
             "lastChanged": "2012-10-24",
             "lastChangedByUserId": 2270
         },
         "created": "2012-10-11",
         "start": "2012-10-20",
         "notes": {"note": [
             {
                 "content": "Having wisdom teeth removed.",
                 "from": "employee"
             },
             {
                 "content": "Get well soon",
                 "from": "manager"
             }
         ]},
         "type": {
             "content": "Vacation",
             "id": 4
         },
         "employee": {
             "content": "Michael Daniels",
             "id": 40350
         },
         "end": "2012-10-25"
     },

I am building my Gson like so:

public class Json {
    private static Gson gson;

    private static class MyNoteClassTypeAdapter implements JsonDeserializer<List<RequestsDTO.Note>> {
        public List<RequestsDTO.Note> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext ctx) {
            List<RequestsDTO.Note> vals = new ArrayList<RequestsDTO.Note>();
            if (json.isJsonArray()) {
                for (JsonElement e : json.getAsJsonArray()) {
                    vals.add((RequestsDTO.Note) ctx.deserialize(e, RequestsDTO.Note.class));
                }
            } else if (json.isJsonObject()) {
                vals.add((RequestsDTO.Note) ctx.deserialize(json,RequestsDTO.Note.class));
            } else {
                throw new RuntimeException("Unexpected JSON type: " + json.getClass());
            }
            return vals;
        }
    }

    public static Gson getGson()
    {
        if (gson == null)
        {
            Type ListType = new TypeToken<List<RequestsDTO.Note>>() {}.getType();
            GsonBuilder builder = new GsonBuilder();
            builder.registerTypeAdapter(DateTime.class, new DateTimeSerializer());
            builder.registerTypeAdapter(ListType, new MyNoteClassTypeAdapter());
            gson = builder.create();
        }
        return gson;
    }
}

the reason for this is because the list of “Note.class” can comeback as a list or as a single object.

And finally building it like this

Json.getGson().fromJson(response, RequestsDTO.class);

Something is going worng ehre and I cant figure out what. It has been troubling me for the past few hours.

I get this error

    11-07 20:04:57.097: E/AndroidRuntime(6963): FATAL EXCEPTION: main
11-07 20:04:57.097: E/AndroidRuntime(6963): java.lang.RuntimeException: Unable to start activity 
11-07 20:04:57.097: E/AndroidRuntime(6963):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1648)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1662)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at android.os.Looper.loop(Looper.java:130)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at android.app.ActivityThread.main(ActivityThread.java:3696)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at java.lang.reflect.Method.invokeNative(Native Method)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at java.lang.reflect.Method.invoke(Method.java:507)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at dalvik.system.NativeStart.main(Native Method)
11-07 20:04:57.097: E/AndroidRuntime(6963): Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1932 column 20
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:81)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:60)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.google.gson.Gson.fromJson(Gson.java:795)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.google.gson.Gson.fromJson(Gson.java:761)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.google.gson.Gson.fromJson(Gson.java:710)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.google.gson.Gson.fromJson(Gson.java:682)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.mokinetworks.bamboohr.service.WebService.getTimeOffRequests(WebService.java:154)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.mokinetworks.bamboohr.ViewRequestActivity.onCreate(ViewRequestActivity.java:29)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1610)
11-07 20:04:57.097: E/AndroidRuntime(6963):     ... 11 more
11-07 20:04:57.097: E/AndroidRuntime(6963): Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1932 column 20
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.google.gson.stream.JsonReader.expect(JsonReader.java:339)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:322)
11-07 20:04:57.097: E/AndroidRuntime(6963):     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:165)
11-07 20:04:57.097: E/AndroidRuntime(6963):     ... 28 more

Does anyone have any idea what is going wrong?

the line 1932 in my json points here

 "created": "2012-10-20",
    "start": "2012-10-29",
    "notes": "",            <---------line 1932
    "type": {
        "content": "Vacation",
        "id": 4
    },
  • 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-14T02:41:36+00:00Added an answer on June 14, 2026 at 2:41 am

    If I’m not mistaken there’s some JSON parse error as mentioned in the error, at:

    line 1932 column 20
    

    What does your JSON look like at that line?

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

Sidebar

Related Questions

i am using following code. public class MyCount extends CountDownTimer { public MyCount(long millisInFuture,
Using following code I try to get updated list of checkbuttons' corresponding text values,
I am using following code to show a spinning wheel: $(#loading) .hide() .ajaxStart(function(){ $(this).show();
I am using following code to get bitmap from url. This function is used
I am using following code for inserting comments: <div id=2 class=789678> <div id=dynamic2> <span
I am using following code to populate DropDown: $(document).ready(function(){ $('#inDistrict').sSelect(); $(#inDistrict).change(function(){ $.getJSON(filldistricts.php,{id: $(this).val(), ajax:
I have a Nancy JSON REST service that uses the following serialisation code... FormatterExtensions.AsJson(this.Response,
I need to add folowing html code to JSON using PHP. <a class=btn btn-mini
i have the following code in c#. I'm using ASP.NET MVC 3. public override
I am using the following code: $.each($('.friendName'), function(){ if($(this).val() != ''){ var idName =

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.