Sample of json text
Sample of json text

Suppose you have a table with a string column that has JSON data encoded in it, like this one below, and you want to parse and query on the data of this column.

val df = Seq(
("{\"id\":1,\"amount\":{\"value\":60,\"currency\":\"BRL\"}}"),
("{\"id\":2,\"amount\":{\"value\":70,\"currency\":\"USD\"}}")
).toDF("my_json_col")

Marcelo Li Koga

Software Engineer and Data Scientist

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store