I have the following JSON to create POJO and that the POJOs will be used in Android Retrofit library but how to create POJO classes with duplicate JSON property name?
My sample JSON:
{
"result": {
"detail": {
"name": "sample"
}
},
"info": {
"detail": {
"user_information": "user"
}
}
}
Here JSON object detail
is duplicated in info
and result
JSON objects, if I create detail.java for result
and detail_.java for info
then get null pointer exception from Retrofit library (I hope, get the exception for property name mismatch with pojo classes).
You can use this site to convert json into pojo classes. Secondary you can declare
Detail
class insideResult
class andInfo
class as a inner class. Example :-View.OnClickListener
andDialogInterface.OnClickListener
. In this example,OnClickListener
interface name is same so we need to write outer class name to distinguish.For your case, this is json converted by site:-