我有一个角度应用程序,可以像这样向服务器发送请求:
$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))))))
有没有办法将其转换为 List[Part]?
case class Part(mfr: String, pn: String)