JSON array:
{
"ID : "ID1",
"books" : [ {
"bookID" : "book1",
"booktype": "pdf"
},{
"bookID" : "book2",
"booktype": "txt"
},{
"bookID" : "book1",
"booktype": "txt"
}
]
}
How to find bookID is duplicated or not here using Java. The JSON array will be big and contains multiple book elements. How to find if any bookID is duplicated?
Expecting an answer in Java 8 using streams or Java.
2
Answers
You can learn more about using Jackson to parse JSON here. Or you can parse them to object and use stream to check for duplicates.
Identify duplicate values for particular element in a JSON array: