android - Retrofit throwing error Expected BEGIN_ARRAY but was BEGIN_OBJECT -


Hello I am new to the retrofit library, I am having trouble parsing some JSN. I have looked at some other solutions on StackHowfortflow but there is not much luck with my problem. I am trying to get a simple webservice to work. Any suggestions would be appreciated ..

Jason File: ["Employee": [{"First Name": "John", "Last Name": "Do"}, {"First Name": "Anna", "Last Name ":" Smith "}, {" first name ":" Peter "," last name ":" jones "}}}

request method

  Public requests for zero Mailer database (string uri) {RestAdapter adapter = new RestAdapter.Builder (). SetEndpoint (ENDPOINT) .build (); Employee API Employee API = Adapter.Create (Employee API Category); EmployeesAPI.getEmployees (new callback & lt; list & employee; employee employee class & gt; & gt; () {@ Override public unqualified success (employee; employee employee class), response to employees response) {List & lt ; String & gt; Name = new array list & lt; String & gt; (); Logs. V ("Ness", "Success of Employee Websites" + Reaction);} @ Override Public Zero Failure (Retroit Errotrift Errors) {Log. V ("NES", "Employee Websites Failed" + RetroThat Error);}}); }   

employee. Java

  public class employees {// list & lt; String & gt; ListOfStrings = New ArrayList & lt; String & gt; (); @ Serialized Name (Value = "Employee") Public List & Employee; & Gt; Employees; Public Zero Set Employees (List & Staff, Employee & Employee; Employee) {this.employees = Staff; } Public Static Class Employee Class {String First Name; String last name; @ Override public string toasting () {returns (first name + + + last name); Public FTO Employee API {@GET ("/ get_names.json") Public Nil Received Employee (Callback   

EmployeesAPI.java

  .employeesclass & gt; & Gt; reaction); }   

The error is occurring

  Employee webserver failed retraction. Retreat error: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: expected BEGIN_ARRAY but line 1 column2 path $   

I understand BEGIN_OBJECT that the data is saying that a Is an object and it should start with an array, but I can not work it thanks .. Thanks

< P> You are matching employee and employee class categories. Instead try to use it:
  public class employee {@ Serialized name (value = "employee") public list & lt; Employee Class & gt; Employees; Public Zero Set Employees (List and Staff; Employee Class; Employee) {This Employee Employee =; } // employeesclass definition}   

Then change your interface and requestEmployeeData accordingly

  Public Interface Employee API {@ GET ("/get_names.json") Public Nil Accepted Employee (Callback & lt; Employee & gt; Response); }    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -