Simply, in your json
{
"r$contentRatings": [
{
"r$scheme": "urn:rt",
"r$rating": "criticSummaryScore=-1,criticSummaryCount=0,criticSummaryCertified=false,criticSummaryRotten=false,fanSummaryScore=75,fanSummaryCount=4"
}
]
}
The elements r$scheme
and r$rating
are not json objects, but json primitives.
Use
JsonPrimitive scheme = contentRatingsList.get(i).getAsJsonObject().getAsJsonPrimitive("r$scheme");
JsonPrimitive rating = contentRatingsList.get(i).getAsJsonObject().getAsJsonPrimitive("r$rating");
Also, note that you have no element named r$subRatings
in your json so you are setting yourself up for a NullPointerException
in the next line.