I have function like this
def jsonFlatten(obj: JsValue, coun: JsObject = Json.obj(), pref: String = ""): JsObject = {
var con = coun
var kel = ""
var el: JsValue = Json.obj()
obj match {
case JsObject(_) =>
var ob = obj.validate[JsObject].get
ob.value.foreach({
case (k, v) =>
if (pref != "") {
kel = pref + "." + k
} else {
kel = k
}
el = v
el match {
case JsObject(_) =>
con = jsonFlatten(el, con.++(con), kel)
case JsArray(_) =>
con = jsonFlatten(el, con.++(con), kel)
case _ =>
con = con.+(kel -> el)
}
})
case _ =>
}
return con
}
That function called on another iteration within thread and I want to optimize this function because it takes lot time (around 300ms) and I have to call lot of that function in iteration.
Is there any suggestion how to optimize that function with concurrency or effective recursion ?
Thanks as