val hostSQLList = jsonObj.getOrElse("hostSQLList", " ").asInstanceOf[List[String]]
var sqlRepMap = mutable.LinkedHashMap[String, Any]()
var sqlStatusMap = mutable.LinkedHashMap[String, Any]()
var sqlSlowQuery = mutable.LinkedHashMap[String, Any]()
hostSQLList.foreach(hostSQL => {
if (hostSQL != null) {
sqlRepMap ++= mutable.LinkedHashMap(hostSQL -> AlertDashboard.checkSQLReplicationLag(hostSQL))
sqlStatusMap ++= mutable.LinkedHashMap(hostSQL -> AlertDashboard.checkSQLStatus(hostSQL))
sqlSlowQuery ++= mutable.LinkedHashMap(hostSQL -> AlertDashboard.checkSQLSlowQuery(hostSQL))
}
else {
sqlRepMap ++= mutable.LinkedHashMap(hostSQL -> "Found nothing")
sqlStatusMap ++= mutable.LinkedHashMap(hostSQL -> "Found nothing")
sqlSlowQuery ++= mutable.LinkedHashMap(hostSQL -> "Found nothing")
}
})
This is giving me the following output :
{
"sqlRepMap":[
{
"_1":"xyz.com",
"_2":{
"18/09/2014 15:00:39_0":0.0,
"18/09/2014 15:30:22_0":0.0,
"18/09/2014 15:49:26_0":0.0
}
}
],
"sqlStatusMap":[
{
"_1":"xyz.com",
"_2":{
"18/09/2014 15:00:39_0":1,
"18/09/2014 15:30:22_0":1,
"18/09/2014 15:49:26_0":1
}
}
],
"sqlSlowQuery":[
{
"_1":"xyz.com",
"_2":{
"18/09/2014 15:00:39_0":0,
"18/09/2014 15:30:22_0":0,
"18/09/2014 15:49:26_0":0
}
}
]
}
When I actually want something like this :
{
"sqlRepMap":[
{
"xyz.com":{
"18/09/2014 15:00:39_0":0.0,
"18/09/2014 15:30:22_0":0.0,
"18/09/2014 15:49:26_0":0.0
}
}
],
"sqlStatusMap":[
{
"xyz.com":{
"18/09/2014 15:00:39_0":1,
"18/09/2014 15:30:22_0":1,
"18/09/2014 15:49:26_0":1
}
}
],
"sqlSlowQuery":[
{
"xyz.com":{
"18/09/2014 15:00:39_0":0,
"18/09/2014 15:30:22_0":0,
"18/09/2014 15:49:26_0":0
}
}
]
}
The same code for insertion in a normal Map is giving me what I want but for a LinkedHashMap it somehow isnt working. Or could there be something wrong with my JSON ParseR? Thanks in advance!