Reputation: 1986
I tried to parse a JSON
response to a single JAVA
Object.This JSON
response included with another JSON arrays and simple fields.
However I could get following result in my attempts.
13:07:25,769 INFO [biz.example.ClentManager] (default task-106) Start findBasicAccountInformation intigartion................................
13:07:25,769 INFO [biz.example.ClentManager] (default task-106) Account No................................200300008212
13:07:25,831 INFO [biz.example.ClentManager] (default task-106) Response : Response{protocol=http/1.1, code=200, message=OK, url=http://192.168.13.40:8092/v2/accounts/200300008212}
13:07:25,832 INFO [biz.example.ClentManager] (default task-106) satatus======================>>>OK
13:07:25,832 INFO [biz.example.ClentManager] (default task-106) statusCode======================>>>200
13:07:25,832 INFO [biz.example.ClentManager] (default task-106) Start : outputJSONObjects
13:07:25,832 INFO [biz.example.ClentManager] (default task-106) jsout : {"StatusCode":200,"TraceId":"89C8F03DC3D946A89F43AE94E0B151A0","Status":"SUCCESS","ErrorList":[],"Result":{"CustomFields":[],"AccountNumber":"200300008212","BranchId":"003","Name":"SAHAN MADURANGA","ShortName":"GHJJKGDJ","CustomerId":"358106","SchemeCode":"SA000","SchemeType":"SBA","Currency":"LKR","Ownership":"E","ChargeLevelCode":"GENRL","CloseFlag":"N","DormantStatus":"A","FrezeCode":" ","JointStatus":"M","ModeOfOpertionalCode":null,"CustomerRelationCode":" ","MinorStatus":"N","TransactionStatus":"T","OpenDate":"2011-12-17T00:00:00"}}
13:07:33,793 ERROR [biz.example.ClentManager] (default task-106) com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "StatusCode" (class biz.spsolutions.edgevantage.workflow.dao.PABCIntegration.ResultBasicAccountInformationDao), not marked as ignorable (5 known properties: "traceId", "status", "result", "errorList", "statusCode"])
at [Source: N/A; line: -1, column: -1] (through reference chain: biz.spsolutions.edgevantage.workflow.dao.PABCIntegration.ResultBasicAccountInformationDao["StatusCode"])
13:10:01,933 WARNING [com.hazelcast.spi.impl.operationservice.impl.InvocationMonitor] (hz._hzInstance_1_dev.InvocationMonitorThread) [IP]:5701 [dev] [3.8.1] MonitorInvocationsTask delayed 147145 ms
13:10:01,933 WARNING [com.hazelcast.spi.impl.operationservice.impl.InvocationMonitor] (hz._hzInstance_1_dev.InvocationMonitorThread) [IP]:5701 [dev] [3.8.1] BroadcastOperationControlTask delayed 145689 ms
13:10:02,021 INFO [biz.example.ClentManager] (default task-106) End findBasicAccountInformation intigartion................................
Do you have any idea ?
Upvotes: 1
Views: 215
Reputation: 13855
You can use some thing like this:
@Data
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@Builder
public class MyDTO implements Serializable {
@JsonProperty("id")
private Long id;
@JsonProperty("tax_id")
private Long taxId;
@JsonProperty("thumbnail")
private String thumbnail;
@JsonProperty("short_description")
private Map<String,Object> shortDescription;
public static MyDTO buildCatalogProductDTO(MyDomain md) {
return MyDTO.builder()
.id(md.getId())
.taxId(catalogProduct.getTaxId())
.shortDescription(SerializationUtil.parseJson(md.getShortDescription()))
.build();
}
where SerializationUtil.parseJson is internally using Gson library for conversion.
Upvotes: 1
Reputation: 925
I think this sums up the error:- com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "StatusCode" (class biz.spsolutions.edgevantage.workflow.dao.PABCIntegration.ResultBasicAccountInformationDao), not marked as ignorable (5 known properties: "traceId", "status", "result", "errorList", "statusCode"])
seems the field names do not match, one starts with capital S and the other small s. Please try changing it.
Upvotes: 1