1

I have streaming data coming in as JSON array and I want flatten it out as a single row in a Spark dataframe using Python.

Here is how the JSON data looks like:

{

"event": [

{

"name": "QuizAnswer",

"count": 1

}

],

"custom": {

"dimensions": [

{

"title": "Are you:"

},

{

"question_id": "5965"

},

{

"option_id": "19029"

},

{

"option_title": "Non-binary"

},

{

"item": "Non-binary"

},

{

"tab_index": "3"

},

{

"tab_count": "4"

},

{

"tab_initial_index": "4"

},

{

"page": "home"

},

{

"environment": "testing"

},

{

"page_count": "0"

},

{

"widget_version": "2.2.44"

},

{

"session_count": "1"

},

{

"quiz_settings_id": "1020"

},

{

"quiz_session": "6e5a3b5c-9961-4c1b-a2af-3374bbeccede"

},

{

"shopify_customer_id": "noid"

},

{

"cart_token": ""

},

{

"app_version": "2.2.44"

},

{

"shop_name": "safety-valve.myshopify.com"

}

],

"metrics": []

}

}

}
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Immad
  • 11
  • 1
  • Possible duplicate : [Pyspark - converting json string to DataFrame](https://stackoverflow.com/questions/49675860/pyspark-converting-json-string-to-dataframe) ? – chateaur Apr 29 '22 at 12:58

0 Answers0