下面列出了怎么用com.fasterxml.jackson.annotation.JsonRawValue的API类实例代码及写法,或者点击链接到github查看源代码。
@JsonRawValue
@JsonProperty("data")
public String getDataAsJson() throws JsonProcessingException {
if (json == null) {
json = JsonUtils.writer().writeValueAsString(data);
}
return json;
}
/**
* TODO(P2) try to do this with aspect @DeclareError
*
* Checks that the method annotated with {@link JsonRawString} also has the
* {@link JsonRawValue} for Jackson to actually serialize as expected.
*
* @param pjp
*/
private void checkMethodHasJsonRawValueAnnotation(ProceedingJoinPoint pjp) {
MethodSignature methodSignature = (MethodSignature) pjp.getSignature();
Method targetMethod = methodSignature.getMethod();
if (targetMethod.getAnnotation(JsonRawValue.class) == null) {
throw new RuntimeException("The method annotated with @JsonRawString must also be annotated with @JsonRawValue");
}
}
@JsonRawValue
public String getBody() {
if(body != null && body.trim().isEmpty()) {
return null;
}
return body;
}
@JsonProperty
@JsonRawValue
public String getConnectorOutputMetadata()
{
return connectorOutputMetadata;
}
@JsonRawValue
public String getProperties() {
return this.properties;
}
@JsonRawValue
public String getProperties() {
return this.properties;
}
@JsonRawValue
public String getValue() {
return value;
}
@JsonRawValue
public String getData() {
return data;
}
@JsonRawValue
public String getDrillThrough() {
return drillThrough;
}
@JsonRawValue
public String getStyle() {
return style;
}
@JsonRawValue
public String getStyle() {
return style;
}
@JsonRawValue
public String getData() {
return data;
}
@JsonValue
@JsonRawValue
public String value() {
return value;
}
@JsonRawValue
@JsonProperty("data")
public void setDataFromJson(JsonNode json) throws JsonProcessingException {
this.data = null;
this.json = JsonUtils.writer().writeValueAsString(json);
}
@JsonRawValue
public final DIDDocument getDidDocument() {
return this.didDocument;
}
@JsonGetter
@JsonRawValue
public String getEvent() {
return event;
}
@JsonRawValue
@JsonProperty("uiConfig")
public String getUIConfig() {
return uiConfig;
}
@JsonProperty(value = "message")
@JsonRawValue
@JsonRawString
public String getMessageAsJson() {
return message;
}
@JsonProperty(value = "errorMessage")
@JsonRawValue
@JsonRawString
public String getErrorMessageAsJson() {
return errorMessage;
}
@JsonRawValue
public String getJsonString() {
return "{\"a\": 1, \"b\": [1,2,3]}";
}
@JsonRawValue
public String getNonJsonString() {
return "This is a simple string that doesn't contain JSON";
}
@JsonRawValue
@JsonRawString
public String getJsonString() {
return "{\"a\": 1, \"b\": [1,2,3]}";
}
@JsonRawValue
@JsonRawString
public String getNonJsonString() {
return "This is a simple string that doesn't contain JSON";
}
@JsonRawValue
public JsonNode getCommand() {
return command;
}
@JsonRawValue
public VersionedCommandOperation setCommand(JsonNode command) {
this.command = command;
return this;
}
@JsonRawValue
@JsonValue
public String getJson() {
return json;
}
@JsonRawValue
public List<Output> getOutput() {
return output;
}
@JsonRawValue
public Object getPayLoad() {
return payLoad;
}
@JsonProperty("rpt")
@JsonRawValue
public String getRpt() {
return this.rpt;
}
@JsonProperty("rt")
@JsonRawValue
public String getRt() {
return this.rt;
}