Spark filter nested json on different data type

Viewed 70

I am working in Spark and reading Json files. In Json, for a section I see different data types. For e.g. in the below Json structure, abc section is of type struct in first record but string type in second record. When I printed the schema via df.printSchema, it returned me string as data type for abc element. I want to filter the records based on the type so I want to retrieve only the records where abc is of struct type. Can someone guide me?

[
  {
    "abc":{
            "code":"TRS"
         }
  },
  {
    "abc": "{\"code\":\"TRS\"}
  }
]
0 Answers
Related