Reputation: 1135
I have a json document
{
description:"desc",
user:{name:"Name", email:"email"},
properties:[
{name:"propName1",val:"propValue1"},
{name:"propName2",val:"propValue2"}
]
}
I defined the class in spring framework:
@Document(collection = "mydocuments")
public class MyDocument extends BaseDocument {
private String description;
....?
}
How do I define user and properties?
Upvotes: 1
Views: 348
Reputation: 8894
You can simply write two classes and create the instance inside the MyDocument class.
class User{
String name;
String email;
// Constructors getters and setters
}
class Property{
String name;
String val;
// Constructors getters and setters
}
@Document(collection = "mydocuments")
public class MyDocument extends BaseDocument {
private String description;
private User user;
private List<Property> properties;
}
Upvotes: 1