Converting SparkDataset to JavaRDD using flatMapToPair

My JSON File contains data like mention below :

[{"StudentName":"John","Subjects":["History","Geography"]},{"StudentName":"Jack","Subjects":["Maths","History"]}]

I am trying to convert above json to key value pair, i.e, {(John,History),(John,Geography),(Jack,Maths), (Jack,History)} however below function generates conversion error.

SQLContext sqlCtx = new SQLContext(ctx);
Dataset<Row> inputDS = sqlCtx.jsonFile("filePath");

JavaPairRDD<String, String> jpRDD = inputDS.toJavaRDD().flatMapToPair(new PairFlatMapFunction<Row, String, String>() {
        @Override
        public Iterator<Tuple2<String, String>> call(Row t) throws Exception {
            List<String> values =  t.getList(1);

            List<Tuple2<String, String>> result = new ArrayList<>();

            for (String str : values) {
                result.add(new Tuple2<String, String>(t.get(0).toString(), str));
            }
            return result;              
        }