I have a class Animal, that extends in Dog and Bagamol and I want to read from a .json file objects of both types and to push into a List. Consider that classes Dog and Bagamol have private members that are the same specified in the json file.
json File
[
{
"type": "Dog", "name": "Bobic",
"age": 3, "price": 1000,
"vaccintated": "yes", "breed": "Doberman",
"height": 100, "weight": 6
},
{
"type": "Bagamol", "name":"Master",
"age": 4, "price": 100000,
"vaccined": "no", "color": "green",
"lenght": 50
}
]
Also, from the list I have to select only objects of one type, for example "Bagamol" and to print them using .stream()
json File
[
{
"type": "Dog", "name": "Bobic",
"age": 3, "price": 1000,
"vaccintated": "yes", "breed": "Doberman",
"height": 100, "weight": 6
},
{
"type": "Bagamol", "name":"Master",
"age": 4, "price": 100000,
"vaccined": "no", "color": "green",
"lenght": 50
}
]
Also, from the list I have to select only objects of one type, for example "Bagamol" and to print them using .stream()