This is my input structure. All the fields here are optional because it can have zero or more elements in this json string. I am fine to use liftweb or regular scala.
{
"fname" : String,
"lname" : String,
"age" : String,
"gender" : String,
"phone" : String,
"mstatus" : String
}
Input: (Note here "mstatus" is not available and "gender" is empty)
{
"fname" : "Thomas",
"lname" : "Peter",
"age" : "20",
"gender" : "",
"phone" : "12345
}
I want to read this Json string and to check whether the key is present and its value is not null then add into a map. My output map would like below.
val inputMap = Map(
"fname" -> "Thomas"
"lname" -> "Peter"
"age" -> "20",
"phone" -> "12345)