API Rest (Swagger)에서 얻은 json 콘텐츠에서 중첩 값을 얻으려고합니다.스칼라 플레이 Json JSResultException 오류 API
play.api.libs.json.JsResultException: JsResultException(errors:List((,List(ValidationError(error.expected.jsstring,WrappedArray())))))
모든 아이디어 :
이{
"status": "OK",
"ts": 1513600944,
"results": {
"total": 4,
"limit": 100,
"page": 1,
"numPages": 1,
"versions": [
{
"id": "consorcio-regional-de-transportes-de-madrid/743/20171127",
"f": {
"id": "consorcio-regional-de-transportes-de-madrid/743",
"ty": "gtfs",
"t": "Metro Ligero de Madrid GTFS",
"l": {
"id": 167,
"pid": 166,
"t": "Madrid, Spain",
"n": "Madrid",
"lat": 40.416775,
"lng": -3.70379
},
"u": {
"i": "http://crtm.maps.arcgis.com/home/item.html?id=aaed26cc0ff64b0c947ac0bc3e033196"
}
},
"ts": 1511848526,
"size": 403388,
"url": "https://transitfeeds.com/p/consorcio-regional-de-transportes-de-madrid/743/20171127/download",
"d": {
"s": "20170106",
"f": "20180629"
},
"err": [],
"warn": []
},
{
"id": "consorcio-regional-de-transportes-de-madrid/743/20170927",
"f": {
"id": "consorcio-regional-de-transportes-de-madrid/743",
"ty": "gtfs",
"t": "Metro Ligero de Madrid GTFS",
"l": {
"id": 167,
"pid": 166,
"t": "Madrid, Spain",
"n": "Madrid",
"lat": 40.416775,
"lng": -3.70379
},
"u": {
"i": "http://crtm.maps.arcgis.com/home/item.html?id=aaed26cc0ff64b0c947ac0bc3e033196"
}
},
"ts": 1506554131,
"size": 403052,
"url": "https://transitfeeds.com/p/consorcio-regional-de-transportes-de-madrid/743/20170927/download",
"d": {
"s": "20170106",
"f": "20180925"
},
"err": [],
"warn": []
},
{
"id": "consorcio-regional-de-transportes-de-madrid/743/20170526",
"f": {
"id": "consorcio-regional-de-transportes-de-madrid/743",
"ty": "gtfs",
"t": "Metro Ligero de Madrid GTFS",
"l": {
"id": 167,
"pid": 166,
"t": "Madrid, Spain",
"n": "Madrid",
"lat": 40.416775,
"lng": -3.70379
},
"u": {
"i": "http://crtm.maps.arcgis.com/home/item.html?id=aaed26cc0ff64b0c947ac0bc3e033196"
}
},
"ts": 1495816290,
"size": 408985,
"url": "https://transitfeeds.com/p/consorcio-regional-de-transportes-de-madrid/743/20170526/download",
"d": {
"s": "20170106",
"f": "20180526"
},
"err": [],
"warn": []
},
{
"id": "consorcio-regional-de-transportes-de-madrid/743/20161012",
"f": {
"id": "consorcio-regional-de-transportes-de-madrid/743",
"ty": "gtfs",
"t": "Metro Ligero de Madrid GTFS",
"l": {
"id": 167,
"pid": 166,
"t": "Madrid, Spain",
"n": "Madrid",
"lat": 40.416775,
"lng": -3.70379
},
"u": {
"i": "http://crtm.maps.arcgis.com/home/item.html?id=aaed26cc0ff64b0c947ac0bc3e033196"
}
},
"ts": 1476308287,
"size": 420670,
"url": "https://transitfeeds.com/p/consorcio-regional-de-transportes-de-madrid/743/20161012/download",
"d": {
"s": "20160101",
"f": "20170621"
},
"err": [],
"warn": []
}
]
}
}
이 문제는 내가이 오류가있다
: 이것은 내가받은 JSON은
val getFeedVersionURL = url("https://api.transitfeeds.com/v1/getFeedVersions?").GET <<? List(
"key" -> someKey,
"feed" -> "consorcio-regional-de-transportes-de-madrid/743",
"page" -> "1",
"limit" -> "10000",
"err" -> "1 (default)",
"warn" ->"1 (default)")
val response : Future[String] = Http.configure(_ setFollowRedirects true)(getFeedVersionURL OK as.String)
val src: String = getFeedVersionURL.toString()
response onComplete {
case Success(content) => {
println("Successful response" + content)
//Parse the content
val jsonObject = Json.parse(content)
//Get url value
val fileDownloadURL = (jsonObject \ "results" \ "versions" \ "url").as[String]
//Save the file
new URL(fileDownloadURL) #> new File("C:/Users//Desktop//file.zip") !!
}
case Failure(t) => {
println("An error has occured: " + t.getMessage)
}
}
: 내가 처음 "URL"값에 액세스 할 ?
' "버전"
as
을 사용하는 것입니다 배열 – cchantep