Attached is my json. I am receiving this from an endpoint. I have the object type in my consuming app. the object contains; success, message and loggedInMember (which is an object). In the json, the feeClasses
contains a lot of fields and objects etc which is why i have not included the whole json. I am only interested in the success
and message
fields.
{
"header":{
"messageId":null,
"receivedTimestamp":1611246394839,
"replyTo":null,
"redelivered":false,
"originator":null
},
"internalId":null,
"auditPoints":[
],
"success":true,
"message":"",
"loggedInMember":{
"feeClasses":{
...CONTAINS A LOT OF FIELDS...
}
}
}
I am trying to map this response to the object type, hence essentially leaving loggedInMembers
null. This is my test I am trying to run:
public void test() throws JsonProcessingException
{
//String json = "{"header":{"messageId":null,"bucketNumber":null,"senderSubId":null,"senderLocationId":null,"onBehalfOfCompId":null,"onBehalfOfSubId":null,"onBehalfOfLocationId":null,"correlationId":null,"receivedTimestamp":1611246394839,"replyTo":null,"redelivered":false,"originator":null},"internalId":null,"auditPoints":[],"success":true,"message":"","loggedInMember":{"memberLoginName":"BMARTINTEST","memberId":"201901241246290000036402D","settlementAccountIds":["201901241246290000036491D"],"parentMemberId":"1","firmId":"990","memberType":"INDIVIDUAL","memberAccountType":"PROD","password":"D1208B304FD7AA6187690A389A5040C1D9B07643","feeClasses":{"byId":{"201902120947520000559606D":{"memberLoginName":"BMARTINTEST","feeClassId":"201508041827550000942152D","memberFeeClassId":"201902120947520000559606D","allocatedDate":{"year":2019,"month":2,"day":12,"timeMillis":1549929600000},"firstUsedForTradeDate":{"year":2019,"month":2,"day":12,"timeMillis":1549929600000},"firstUsedForSettlementDate":null,"usableFromDate":{"year":2019,"month":2,"day":12,"timeMillis":1549929600000},"usableToDate":{"year":2019,"month":2,"day":19,"timeMillis":1550534400000},"usableToTimestamp":1550613600000,"usableBusinessDaysAllocated":6,"usableBusinessDaysRemaining":0,"narrative":"Bonus assigned to member at first-time funding of amount 4000.00 : Set expiration date/time","disabled":false,"usableForTrade":true,"usableForSettlement":true},"202001290940390000868824D":{"memberLoginName":"BMARTINTEST","feeClassId":"202001290940340000776406D","memberFeeClassId":"202001290940390000868824D","allocatedDate":{"year":2020,"month":1,"day":29,"timeMillis":1580256000000},"firstUsedForTradeDate":null,"firstUsedForSettlementDate":null,"usableFromDate":{"year":2020,"month":1,"day":6,"timeMillis":1578268800000},"usableToDate":{"year":2020,"month":2,"day":27,"timeMillis":1582761600000},"usableToTimestamp":1582840800000,"usableBusinessDaysAllocated":0,"usableBusinessDaysRemaining":0,"narrative":"Added NO_FEES_CLASS","disabled":false,"usableForTrade":true,"usableForSettlement":true},"201901241246290000036417D":{"memberLoginName":"BMARTINTEST","feeClassId":"201508041736360000943781D","memberFeeClassId":"201901241246290000036417D","allocatedDate":{"year":2019,"month":1,"day":24,"timeMillis":1548288000000},"firstUsedForTradeDate":null,"firstUsedForSettlementDate":null,"usableFromDate":{"year":2019,"month":1,"day":24,"timeMillis":1548288000000},"usableToDate":null,"usableToTimestamp":null,"usableBusinessDaysAllocated":0,"usableBusinessDaysRemaining":0,"narrative":null,"disabled":false,"usableForTrade":true,"usableForSettlement":true}},"empty":false},"legalName":"Martin Birch","taxId":"345335454","taxCountryId":"US","currency":"USD","lastTradeId":null,"introducingBrokerMemberId":null,"introducingBrokerMemberName":null,"introducingBrokerMemberCode":null,"clearedByMemberId":"SECOND_TEST","clearedByMemberLoginName":null,"memberProblems":[],"emailNotificationEnabled":true,"rtafLevelId":0,"rtafAmount":0,"maxNumberOfPositionAccounts":1,"ciciIdentifier":null,"traderRequired":false,"interestClass":"INDIVIDUAL","memberCreatedDate":1548333989000,"parentMemberLoginNames":["NADEX.COM","NADEX"],"demoStartDate":null,"demoEndDate":null,"clientIdMaxLimit":null,"memberAccountApplicationFieldData":null,"rank":0,"uuid":"201901241246290000036395D","referrerId":"raf4qam5h00s36d","testMember":false},"allReplyToSource":[],"sendToOriginatorOnly":false}";
String json = "{
" +
" "header":{
" +
" "messageId":null,
" +
" "receivedTimestamp":1611246394839,
" +
" "replyTo":null,
" +
" "redelivered":false,
" +
" "originator":null
" +
" },
" +
" "internalId":null,
" +
" "auditPoints":[
" +
"
" +
" ],
" +
" "success":true,
" +
" "message":"",
" +
" "loggedInMember":{
" +
" "feeClasses":{
" +
"
" +
" }
" +
" }
" +
"}";
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
objectMapper.addMixIn(LogonResponseMessage.class, LogonResponseMixin.class);
LogonResponseMessage responseMessage = objectMapper.readValue(json, LogonResponseMessage.class);
System.out.println(responseMessage);
}
My mixin:
public abstract class LogonResponseMixin
{
LogonResponseMixin(@JsonProperty("success") boolean success, @JsonProperty("message") String message){};
@JsonIgnore
abstract Member loggedInMember();
@JsonIgnore
abstract MemberFeeClasses feeClasses();
@JsonIgnore
abstract Header header();
}
I am getting the following error: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of domain.xyz.MemberFeeClasses (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
Am i creating the mixin wrong? I have asked in a previous question and using mixin was the general consensus but it doesn't seem to play ball with me.
Thank you.