How to parse nested JSON using Scala Spark ?

Handing nested JSON could be a very frustrating task. If you do not know the concepts. we often face many challenges while dealing with nested JSON structure .Here I will try to explain all concepts in few steps.

For example -

JSON STRUCTURE{
“student_name”:”Ram kumar”,
“DOB” : “10–02–1995”
“address”:{“city”:”kolkata”,”pin_code”:811320},
“contact_number”:{“primary”:963343944,”secondary”:883673363 }
}