1
我有一個角度的應用程序,發送到服務器的請求,像這樣:Scala如何將JsonAST.JValue轉換爲類型?
$scope.downloadPartDetails = (parts, e) ->
req = {
method: 'POST',
url: '/downloads/partdetails',
headers: {
'Content-Type': "application/json; charset=utf-8"
},
data: { parts: [
{manufacturer: "mfr1", partNumber: "part num1"},
{manufacturer: "mfr2", partNumber: "part num2"},
{manufacturer: "mfr3", partNumber: "part num3"}
] }
}
$http(req)
它顯示了在服務器上是這樣的:
JArray(List(JObject(List(JField(manufacturer,JString(mfr1)), JField(partNumber,JString(part num1)))), JObject(List(JField(manufacturer,JString(mfr2)), JField(partNumber,JString(part num2)))), JObject(List(JField(manufacturer,JString(mfr3)), JField(partNumber,JString(part num3))))))
有沒有辦法將其轉換爲一個列表[部分]?
case class Part(mfr: String, pn: String)
進行了更改並且工作正常。謝謝。 –