Skip to content

Commit

Permalink
Replace Poison with Jason, resolves HashNuke#224
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewDryga committed Nov 29, 2018
1 parent 08626c9 commit 4e39c18
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/hound/browsers/firefox/profile.ex
Expand Up @@ -25,7 +25,7 @@ defmodule Hound.Browser.Firefox.Profile do
def serialize_preferences(profile) do
profile.prefs
|> Enum.map_join("\n", fn {key, value} ->
~s[user_pref("#{key}", #{Poison.encode!(value)});]
~s[user_pref("#{key}", #{Jason.encode!(value)});]
end)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/hound/element.ex
Expand Up @@ -27,9 +27,9 @@ defmodule Hound.Element do
end
end

defimpl Poison.Encoder, for: Hound.Element do
defimpl Jason.Encoder, for: Hound.Element do
def encode(%{uuid: uuid}, options) do
Poison.Encoder.Map.encode(%{"ELEMENT" => uuid}, options)
Jason.Encode.map(%{"ELEMENT" => uuid}, options)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/hound/request_utils.ex
Expand Up @@ -28,7 +28,7 @@ defmodule Hound.RequestUtils do
has_body = params != %{} && type == :post
{headers, body} = cond do
has_body && options[:json_encode] != false ->
{[{"Content-Type", "text/json"}], Poison.encode!(params)}
{[{"Content-Type", "text/json"}], Jason.encode!(params)}
has_body ->
{[], params}
true ->
Expand Down
2 changes: 1 addition & 1 deletion lib/hound/response_parser.ex
Expand Up @@ -66,7 +66,7 @@ defmodule Hound.ResponseParser do
Decodes a response body
"""
def decode_content([]), do: Map.new
def decode_content(content), do: Poison.decode(content)
def decode_content(content), do: Jason.decode(content)

defmacro __before_compile__(_env) do
quote do
Expand Down
2 changes: 1 addition & 1 deletion lib/hound/response_parsers/phantom_js.ex
Expand Up @@ -4,7 +4,7 @@ defmodule Hound.ResponseParsers.PhantomJs do
use Hound.ResponseParser

def handle_error(%{"message" => message} = value) do
case Poison.decode(message) do
case Jason.decode(message) do
{:ok, decoded_error} -> decoded_error
_ -> value
end |> do_handle_error
Expand Down
6 changes: 3 additions & 3 deletions mix.exs
Expand Up @@ -18,8 +18,8 @@ defmodule Hound.Mixfile do

def application do
[
applications: [:hackney, :poison, :logger],
mod: { Hound, [] },
extra_applications: [:logger],
mod: {Hound, []},
description: 'Integration testing and browser automation library',
]
end
Expand All @@ -28,7 +28,7 @@ defmodule Hound.Mixfile do
defp deps do
[
{:hackney, "~> 1.5"},
{:poison, "~> 1.4.0"},
{:jason, "~> 1.1"},
{:earmark, "~> 1.2", only: :docs},
{:ex_doc, "~> 0.16", only: :docs}
]
Expand Down
8 changes: 5 additions & 3 deletions mix.lock
@@ -1,10 +1,12 @@
%{"certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], [], "hexpm"},
%{
"certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], [], "hexpm"},
"earmark": {:hex, :earmark, "1.2.3", "206eb2e2ac1a794aa5256f3982de7a76bf4579ff91cb28d0e17ea2c9491e46a4", [:mix], [], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.16.2", "3b3e210ebcd85a7c76b4e73f85c5640c011d2a0b2f06dcdf5acdb2ae904e5084", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},
"hackney": {:hex, :hackney, "1.9.0", "51c506afc0a365868469dcfc79a9d0b94d896ec741cfd5bd338f49a5ec515bfe", [:rebar3], [{:certifi, "2.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
"idna": {:hex, :idna, "5.1.0", "d72b4effeb324ad5da3cab1767cb16b17939004e789d8c0ad5b70f3cea20c89a", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"},
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"},
"poison": {:hex, :poison, "1.4.0", "cd5afb9db7f0d19487572fa28185b6d4de647f14235746824e77b3139b79b725", [], [], "hexpm"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], [], "hexpm"}}
"unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], [], "hexpm"},
}
2 changes: 1 addition & 1 deletion test/element_test.exs
Expand Up @@ -6,7 +6,7 @@ defmodule ElementTest do
test "encoding to JSON" do
uuid = "some-uuid"
element = %Element{uuid: uuid}
assert Poison.encode!(element) == ~s({"ELEMENT":"#{uuid}"})
assert Jason.encode!(element) == ~s({"ELEMENT":"#{uuid}"})
end

test "string representation" do
Expand Down

0 comments on commit 4e39c18

Please sign in to comment.