Update remote context processing code to use Jason instead of Poison
This commit is contained in:
parent
e658b3c9c1
commit
ae50884370
2 changed files with 9 additions and 10 deletions
|
@ -71,7 +71,7 @@ defmodule JSON.LD.Context do
|
|||
end
|
||||
document = cond do
|
||||
is_map(document) -> document
|
||||
is_binary(document) -> case Poison.decode(document) do
|
||||
is_binary(document) -> case Jason.decode(document) do
|
||||
{:ok, result} -> result
|
||||
{:error, reason} -> raise JSON.LD.InvalidRemoteContextError,
|
||||
message: "Context is not a valid JSON document: #{inspect reason}"
|
||||
|
|
|
@ -4,17 +4,16 @@ defmodule JSON.LD.DocumentLoader.Default do
|
|||
alias JSON.LD.DocumentLoader.RemoteDocument
|
||||
|
||||
def load(url, _options) do
|
||||
with {:ok, res} <- HTTPoison.get(url, [accept: "application/ld+json"],
|
||||
[follow_redirect: true]),
|
||||
{:ok, data} <- Poison.decode(res.body)
|
||||
with {:ok, res} <-
|
||||
HTTPoison.get(url, [accept: "application/ld+json"], [follow_redirect: true]),
|
||||
|
||||
{:ok, data} <-
|
||||
Jason.decode(res.body)
|
||||
do
|
||||
result = %RemoteDocument{
|
||||
{:ok, %RemoteDocument{
|
||||
document: data,
|
||||
document_url: res.request_url,
|
||||
}
|
||||
{:ok, result}
|
||||
else
|
||||
{:error, reason} -> {:error, reason}
|
||||
document_url: res.request_url
|
||||
}}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue