I am trying to save the following Java object as a document in MongoDB, here are my classes:
public class GenericIpConfig {
String connection_type;
String port;
String port_ingenico;
String ip;
String ip_ingenico;
String id_ingenico;
boolean active_ingenico;
long lastPushTime;
}
@Data
@Document(collection = "generic_device_config")
public class GenericDeviceConfig {
@Id
String _id;
String storeCode;
String companyCode;
long updated;
boolean enabled;
ArrayList<SerialPort> serialPorts;
String companyId;
GenericIpConfig ipConfig;
}
And this is the request I am sending with POSTMAN:
{
"updated":0,
"enabled":true,
"serialPorts":[],
"companyId":"600",
"companyCode":"0",
"storeCode":"0",
"ipConfig": {
"connection_type":"ETHERNET",
"port": "23",
"port_ingenico": "",
"ip": "192.168.10.55",
"ip_ingenico": "",
"id_ingenico": "",
"active_ingenico": false,
"lastPushTime": 0
}
}
For some reason, I keep getting the following error:
JSON parse error: Unrecognized field \"connection_type\" (class it.igesa.monitoringsystem.model.mongo.device.config.GenericIpConfig), not marked as ignorable; nested exception is com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field \"connection_type\" (class it.igesa.monitoringsystem.model.mongo.device.config.GenericIpConfig), not marked as ignorable (0 known properties: ]
I feel like my code is missing something, since this is the first time I am working with SpringBoot/MongoDB;