我在 elixir 中调用 HTTP Rest API
url = "http://localhost:8080/getScoreData"
case HTTPoison.get(url) do
{:ok, %{status_code: 200, body: body}} ->
Logger.info("body is #{inspect(body)}")
overall_score = Jason.decode!(body, as: [%OverallScore{}])
{:ok, overall_score}
end
在网络浏览器中返回
{
"avgPass": 85.55,
"avgFail": 14.45,
"totalStudents": 80.0,
"myScoreSchema": [
{
"average": 80.0,
"count": 8.0,
"percent": 80.0,
"name": "John"
},
{
"average": 0.0,
"count": 0.0,
"percent": 0.0,
"name": "Cena"
},
{
"average": 0.0,
"count": 0.0,
"percent": 0.0,
"name": "Sunny"
},
{
"average": 0.0,
"count": 0.0,
"percent": 0.0,
"name": "Michael"
}
]
}
但是Logger.info("body is #{inspect(body)}")
从上面的代码行开始的日志删除
了数据并返回下面的数据
{
"avgPass": 85.55,
"avgFail": 14.45,
"totalStudents": 80.0,
"myScoreSchema": [
{
"average": 80.0,
"count": 8.0,
"percent": 80.0,
"name": "John"
},
{
"average": 0.0,
"count": 0.0,
"percent": 0.0,
"name": "Cena Sunny Michael"
}
]
}
尽管这是一个智能功能,但我不想要这个重复数据删除功能。如何避免重复数据删除。