title: Process each json record in json RDD using Spark with Scala
body: <p>I need help with the below scenario:</p>
  
  <p>I will get the data from Kafka in the following JSON format to spark streaming</p>
  
  <pre><code>{"id" : 1 , "data" : "AFGH00101219"}
  {"id" : 2 , "data" : "AFGH00101215"}
  {"id" : 2 , "data" : "AFGH00101216"}
  {"id" : 3 , "data" : "AFGH00101218"}
  
  val messages= KafkaUtils.createDirectStream[String, String, StringDecoder, StringDecoder](ssc, kafkaParams, topics)
  </code></pre>
  
  <p>Now I want to process each JSON record from the messages and each record in turn returns set of records. Please give me some ideas to do the below task.</p>
  
  <pre><code>val output = messages.map(row =&gt;
  {
  //here I will get each json record. My doubt is how to extract id and data 
  //filed values from row and store it into variables.
  //Here I need to decode the data filed value which is in hexa decimal format 
  //to decimal format.
  }
  </code></pre>
  
  <p>Thanks in advance. Please let me know if the question is not clear.</p>