I am facing problem regarding creating dynamic attributes with different data types (int, boolean, float, double, long, String, byte, ...) in Java using Spring Boot REST API and store in MongoDB collection. How can I get a solution for this?
@Field(value = "attributes")
Map<String, Object> attributes = new LinkedHashMap<>();
/*
* setter for map attributes
*/
@JsonAnySetter
public void setAttributes(String key, Object value) {
Set<Map.Entry<String, Object>> s = attributes.entrySet();
for (Map.Entry<String, Object> it : s) {
key = it.getKey();
value = it.getValue();
this.attributes.put(key, value);
}
}
I am using this one but it's storing all data types as String only.
I need not require to store any value only I need to store attributes for particular data types.
