我的api是:
以上URL中的JSON响应如下
{"Table":[{"Error_code":"0","Error_Message":"Success","EncryptionFlag":"N"}
],"Table1":[{"Fund_Id":"128","FN_FundDescription":"ABCD FUND"},{"Fund_Id":"178","FN_FundDescription":"XYZ FUND"},{"Fund_Id":"116","FN_FundDescription":"Pritham FUND"},{"Fund_Id":"118","FN_FundDescription":"Ram FUND"},{"Fund_Id":"130","FN_FundDescription":"Mannu FUND"}]}
我在mainactivity.java中将baseurl设为https://api.domainname/25/SmartService.svc
[谁能告诉我如何以@GET(“”);的形式调用Interface.java类中的url部分的其余部分]
我已经生成了一个pojo类,它也生成了3个类。
1 .Example.java
package com.example.retrofit;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Example {
@SerializedName("Table")
@Expose
private List<Table> table = null;
@SerializedName("Table1")
@Expose
private List<Table1> table1 = null;
public List<Table> getTable() {
return table;
}
public void setTable(List<Table> table) {
this.table = table;
}
public List<Table1> getTable1() {
return table1;
}
public void setTable1(List<Table1> table1) {
this.table1 = table1;
}
}
2.Table.java
package com.example.retrofit;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Table {
@SerializedName("Error_code")
@Expose
private String errorCode;
@SerializedName("Error_Message")
@Expose
private String errorMessage;
@SerializedName("EncryptionFlag")
@Expose
private String encryptionFlag;
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
public String getEncryptionFlag() {
return encryptionFlag;
}
public void setEncryptionFlag(String encryptionFlag) {
this.encryptionFlag = encryptionFlag;
}
}
3 .Table1.java包com.example.retrofit;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Table1 {
@SerializedName("Fund_Id")
@Expose
private String fundId;
@SerializedName("FN_FundDescription")
@Expose
private String fNFundDescription;
public String getFundId() {
return fundId;
}
public void setFundId(String fundId) {
this.fundId = fundId;
}
public String getFNFundDescription() {
return fNFundDescription;
}
public void setFNFundDescription(String fNFundDescription) {
this.fNFundDescription = fNFundDescription;
}
}
所以请任何人帮助我如何从剩余的URL中获取参数并将其与querymap concept一起使用。这样我就可以在recyclerview中显示json响应。
我认为您不应该使用https://api.domainname/25/SmartService.svc
作为基本网址。您应该做的是:
进行以下更改: