0
我初學瑟茜,我想從這個JSON解析JSON陣列瑟茜
[
{
"sha":"7fd1a60b01f91b314f59955a4e4d4e80d8edf11d",
"commit":{
"author":{
"name":"The Octocat",
"email":"[email protected]",
"date":"2012-03-06T23:06:50Z"
},
"committer":{
"name":"The Octocat",
"email":"[email protected]",
"date":"2012-03-06T23:06:50Z"
},
"message":"Merge pull request #6 from Spaceghost/patch-1\n\nNew line at end of file.",
},
"url":"https://api.github.com/repos/octocat/Hello-World/commits/7fd1a60b01f91b314f59955a4e4d4e80d8edf11d",
},
{
"sha":"762941318ee16e59dabbacb1b4049eec22f0d303",
"commit":{
"author":{
"name":"Johnneylee Jack Rollins",
"email":"[email protected]",
"date":"2011-09-14T04:42:41Z"
},
"committer":{
"name":"Johnneylee Jack Rollins",
"email":"[email protected]",
"date":"2011-09-14T04:42:41Z"
},
"message":"New line at end of file. --Signed off by Spaceghost",
},
"url":"https://api.github.com/repos/octocat/Hello-World/commits/762941318ee16e59dabbacb1b4049eec22f0d303",
},
]
檢索信息,我不知道如何驗證碼不趕有關「作者」
信息val doc= parse(response.json.toString()).getOrElse(Json.Null)
doc.hcursor.downArray.downField("commit").right.as[Seq[String]] match {
case Left(failure) => println("Fail")
case Right(json) => println("Ok")
}
你有什麼想法嗎?
在此先感謝,
你能否提供一些更多的信息?什麼類型是「響應」?你的進口是什麼? – Tanjin