I have a *.json file which contains my custom landmarks. I am able to read this file with:
import spray.json._
import DefaultJsonProtocol._
import upickle.default._
import org.json4s._
import org.json4s.native.JsonMethods._
val jsonLandmarkFile = new File(referenceDir, "myLM.json")
val json_content = scala.io.Source.fromFile(jsonLandmarkFile).mkString.parseJson
println("JSON string read:")
val json = json_content.prettyPrint
println(json)
I get this:
{
"APPLICATION": {
"@applicationVersion": "APPLICATION-1.0.0",
"ApplicationInfo": {
"value": {
"@type": "Type",
"@version": "1.1",
"value": [{
"#text": "date",
"@key": "date",
"@type": "String"
}, {
"#text": "Info",
"@key": "xxx",
"@type": "xxx"
}
}]
}
}
"Landmarks": {
"value": {
"@type": "Type",
"@version": "1.1",
"value": [{
"#text": "-4.36 -21.5 -54.6",
"@key": "LM1",
"@type": "Type"
}, {
"#text": "-4.1 -19.2 47.2",
"@key": "LM2",
"@type": "Type"
}, {
"#text": "-3.9 6.16 253.6",
"@key": "LM3",
"@type": "Type"
}
}]
}
}
I'd like to convert those landmarks to Scalismo landmarks from json_content. But I am stuck on how to do this in Scala (sorry, I am new to Scala and json as well). I had a look in LandmarkIO.scala and tried this:
val landmarks = json_content.asJsObject.getFields("Landmarks")
but I wasn't able to get something as json_content is a very nested json file ...
Could you give me some hints, please.