我知道这个问题问here但是我无法解决它同样的错误。我的一些Web服务工作正常,但我的一些Web服务显示此错误。以下是我的基本网址代码。
ServiceGenerators
private static final String BASE_URL = "http://myurl.com/";
private static Retrofit.Builder builder =
new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create());
private static Retrofit retrofit = builder.build();
private static OkHttpClient.Builder httpClient =
new OkHttpClient.Builder();
private static HttpLoggingInterceptor logging =
new HttpLoggingInterceptor()
.setLevel(HttpLoggingInterceptor.Level.BODY);
public static <T> T createService(Class<T> serviceClass) {
if (!httpClient.interceptors().contains(logging)) {
httpClient.addInterceptor(logging);
builder.client(httpClient.build());
retrofit = builder.build();
}
return retrofit.create(serviceClass);
}
}
以下是我的json回复第一个响应正在起作用,第二个响应不起作用
工作回复
{
"status": "success",
"records": [
{
"bloodpressure_id": "12",
"user_id": "73",
"relative_id": "102",
"report_date": "2017-03-15",
"report_time": "03:01:00",
"person": "Lalit",
"systolic": "120",
"diastolic": "50"
},
{
"bloodpressure_id": "14",
"user_id": "73",
"relative_id": "102",
"report_date": "2017-03-16",
"report_time": "07:27:00",
"person": "Lalit",
"systolic": "120",
"diastolic": "80"
},
{
"bloodpressure_id": "15",
"user_id": "73",
"relative_id": "102",
"report_date": "2017-03-17",
"report_time": "07:28:00",
"person": "Lalit",
"systolic": "140",
"diastolic": "100"
},
{
"bloodpressure_id": "16",
"user_id": "73",
"relative_id": "102",
"report_date": "2017-03-18",
"report_time": "07:28:00",
"person": "Lalit",
"systolic": "160",
"diastolic": "120"
},
{
"bloodpressure_id": "17",
"user_id": "73",
"relative_id": "102",
"report_date": "2017-03-19",
"report_time": "07:29:00",
"person": "Lalit",
"systolic": "135",
"diastolic": "85"
},
{
"bloodpressure_id": "18",
"user_id": "73",
"relative_id": "102",
"report_date": "2017-03-20",
"report_time": "07:29:00",
"person": "Lalit",
"systolic": "137",
"diastolic": "99"
},
{
"bloodpressure_id": "19",
"user_id": "73",
"relative_id": "102",
"report_date": "2017-03-21",
"report_time": "07:29:00",
"person": "Lalit",
"systolic": "148",
"diastolic": "121"
},
{
"bloodpressure_id": "20",
"user_id": "73",
"relative_id": "102",
"report_date": "2017-03-22",
"report_time": "07:30:00",
"person": "Lalit",
"systolic": "115",
"diastolic": "110"
},
{
"bloodpressure_id": "21",
"user_id": "73",
"relative_id": "102",
"report_date": "2017-03-23",
"report_time": "07:30:00",
"person": "Lalit",
"systolic": "129",
"diastolic": "90"
},
{
"bloodpressure_id": "22",
"user_id": "73",
"relative_id": "102",
"report_date": "2017-03-24",
"report_time": "07:31:00",
"person": "Lalit",
"systolic": "168",
"diastolic": "108"
},
{
"bloodpressure_id": "25",
"user_id": "73",
"relative_id": "103",
"report_date": "2017-03-26",
"report_time": "01:26:00",
"person": "aaq",
"systolic": "120",
"diastolic": "250"
},
{
"bloodpressure_id": "28",
"user_id": "73",
"relative_id": "102",
"report_date": "2017-07-08",
"report_time": "01:24:00",
"person": "Lalit",
"systolic": "90",
"diastolic": "90"
},
{
"bloodpressure_id": "32",
"user_id": "73",
"relative_id": "113",
"report_date": "0000-00-00",
"report_time": "00:00:16",
"person": "Sushil",
"systolic": "120",
"diastolic": "320"
},
{
"bloodpressure_id": "33",
"user_id": "73",
"relative_id": "113",
"report_date": "0000-00-00",
"report_time": "00:00:16",
"person": "Sushil",
"systolic": "111",
"diastolic": "211"
},
{
"bloodpressure_id": "34",
"user_id": "73",
"relative_id": "113",
"report_date": "0000-00-00",
"report_time": "00:00:16",
"person": "Sushil",
"systolic": "100",
"diastolic": "140"
},
{
"bloodpressure_id": "35",
"user_id": "73",
"relative_id": "113",
"report_date": "0000-00-00",
"report_time": "00:00:16",
"person": "Sushil",
"systolic": "120",
"diastolic": "1340"
},
{
"bloodpressure_id": "36",
"user_id": "73",
"relative_id": "113",
"report_date": "0000-00-00",
"report_time": "00:00:17",
"person": "Sushil",
"systolic": "1111",
"diastolic": "5555"
}
]
}
不响应
{
"status": "success",
"records": [
{
"measurements_id": "24",
"user_id": "73",
"relative_id": "102",
"person": "Lalit",
"report_date": "2017-07-01",
"report_time": "05:30:00",
"record_name": "aaaaq",
"record_details": "asda ads ad"
},
{
"measurements_id": "25",
"user_id": "73",
"relative_id": "102",
"person": "Lalit",
"report_date": "2017-07-03",
"report_time": "05:30:00",
"record_name": "eeeq",
"record_details": "cxvxv"
}
]
}
错误消息
Use JsonReader.setLenient(true) to accept malformed JSON at line 2 column 1 path $
班级模特 测量列表
public class measurementsListing {
String status;
List<ReportAndMeasurementsModel> records;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public List<ReportAndMeasurementsModel> getRecords() {
return records;
}
public void setRecords(List<ReportAndMeasurementsModel> records) {
this.records = records;
}
}
ReportAndMeasurementsModel
public class ReportAndMeasurementsModel {
String ReportFor;
String report_date;
String report_time;
String RecordName;
String record_name;
String Attachments;
String measurements_id;
String user_id;
String relative_id;
String record_details;
public String getReport_date() {
return report_date;
}
public void setReport_date(String report_date) {
this.report_date = report_date;
}
public String getReport_time() {
return report_time;
}
public void setReport_time(String report_time) {
this.report_time = report_time;
}
public String getRecord_name() {
return record_name;
}
public void setRecord_name(String record_name) {
this.record_name = record_name;
}
public String getMeasurements_id() {
return measurements_id;
}
public void setMeasurements_id(String measurements_id) {
this.measurements_id = measurements_id;
}
public String getUser_id() {
return user_id;
}
public void setUser_id(String user_id) {
this.user_id = user_id;
}
public String getRelative_id() {
return relative_id;
}
public void setRelative_id(String relative_id) {
this.relative_id = relative_id;
}
public String getRecord_details() {
return record_details;
}
public void setRecord_details(String record_details) {
this.record_details = record_details;
}
public ReportAndMeasurementsModel(String mReportFor, String mDate, String mTime, String mRecordName, String mRecordDetails, String mattachment) {
this.ReportFor=mReportFor;
this.report_date=mDate;
this.report_time=mTime;
this.RecordName=mRecordName;
this.record_name=mRecordDetails;
this.Attachments=mattachment;
}
public String getReportFor() {
return ReportFor;
}
public void setReportFor(String reportFor) {
ReportFor = reportFor;
}
public String getDate() {
return report_date;
}
public void setDate(String date) {
report_date = date;
}
public String getTime() {
return report_time;
}
public void setTime(String time) {
report_time = time;
}
public String getRecordName() {
return RecordName;
}
public void setRecordName(String recordName) {
RecordName = recordName;
}
public String getRecordDetails() {
return record_name;
}
public void setRecordDetails(String recordDetails) {
record_name = recordDetails;
}
public String getAttachments() {
return Attachments;
}
public void setAttachments(String attachments) {
Attachments = attachments;
}
}
欢迎任何帮助