0
  1. Problem: How to identify that my Model object (POJO) members amount is not equal to the JSON members.

  2. Notes:

  1. Purpose: It is necessary for the integration level testing needs. I have an expected JSON string, getting the actual JSON string (for example from service) in case if the actual JSON has more members than my model I would like to be aware of this issue, let it be an exception throwing.

  2. Code:

ActualPayLoad.json

{
    "num1": 1,
    "bool1": true,
    "str1": "firstMissedInModel",
    "nested": {
        "num2": 1,
        "bool2": true,
        "str2": "secondMissedInModel"
    }
}

TopModel.class

public class TopModel {

    private Boolean bool1;
    private NestedModel nested;
    private Long num1;
//    private String str1;
}

NestedModel.class

public class NestedModel {
    private Boolean bool2;
    private Long num2;
//    private String str2;
}

Thank you for an eforts.

0 Answers0