如何发送POST请求中的JSON数据变白JSON对象

时间:2018-07-18 14:44:39

标签: json jackson postman spring-restcontroller

如何从Spring Rest控制器的POST主体中的POST请求发送JSON数据以美白JSON对象。 我需要将该数据保存到列类型为JSON的Postgres DB中。

我需要将PostMan中的以下JSON作为POST请求发送到SPring Rest控制器,但是我无法将数据保存在控制器中,控制器中的数据为null,但是当我给出List时,我将遇到错误。 / p>

  

JSON解析错误:无法从START_OBJECT令牌中反序列化java.util.ArrayList的实例;嵌套的异常是com.fasterxml.jackson.databind.exc.MismatchedInputException:无法从[Source:(PushbackInputStream)处的START_OBJECT令牌中反序列化java.util.ArrayList的实例。行:1,列:1]“,   “ path”:“ / configJsondata”

Postman的输入Json是:

{
 "GenericValidation":[{"MinimumFieldsCheck":true},{"MirrorCopyAccountCheck":true},{"DuplicateAccountCheck":false},{"CleanClaimCheck":false},{"Segregating":true}],
 "HL7Specification":[{"MinimumFieldsCheck":true},{"MirrorCopyAccountCheck":true},{"DuplicateAccountCheck":false},{"CleanClaimCheck":false},{"Segregating":true}]
}

@PostMapping(value = "facility/insertConfig")
public ResponseEntity<?> insertCoderConfiguration(@RequestBody CoderConfigvalue requestvalue) {
int status = 0;
try {

    status = coderInboxFetchRecordsService.saveCoderConfiguration(requestvalue);

} catch (Exception e) {
    LOGGER.error(" Exception while fetching record from DB", e.getMessage());
}

return ResponseEntity.status(HttpStatus.OK).body(status);
}


public class CoderConfigvalue implements Serializable {

/**
 * 
 */
private static final long serialVersionUID = -1749526768701725321L;
private String facilitycode;
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(Include.NON_EMPTY)
@JsonProperty("GenericValidation")
private List<Map<String, Boolean>> GenericValidation;
@JsonInclude(Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonProperty("HL7Specification")
private List<Map<String, Boolean>> HL7Specification;

0 个答案:

没有答案
相关问题