Java 使用改装的特殊字符发布
我需要发送一个POST请求,其主体如下:Java 使用改装的特殊字符发布,java,retrofit,Java,Retrofit,我需要发送一个POST请求,其主体如下: { "@class": ".RegistrationRequest", "displayName": "string", "password": "string", "requestId": "string", "segments": {}, "userName": "string" } 我的接口类是: public interface GSInterface { @POST(ENDPOINT_REGISTER)
{
"@class": ".RegistrationRequest",
"displayName": "string",
"password": "string",
"requestId": "string",
"segments": {},
"userName": "string"
}
我的接口类是:
public interface GSInterface {
@POST(ENDPOINT_REGISTER)
Call<RegistrationResponse> postRegister(
@Field("@class") String gsclass,
@Body User user);
}
公共接口GSInterface{
@POST(端点寄存器)
呼叫寄存(
@字段(“@class”)字符串gsclass,
@身体使用者);
}
我不能在用户对象内创建参数“@class”,至少我不知道如何创建
另外,将“@class”作为@Field、@Part或@Query不起作用。使用
@SerializedName
注释提供字段名
class User {
@SerializedName("@class")
private String gsClass;
...
}