summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Busby <contact@benbusby.com>2022-02-14 11:21:32 -0700
committerBen Busby <contact@benbusby.com>2022-02-14 11:21:32 -0700
commit5235f5a3bf620a787d0d2ee0021336c893ffa013 (patch)
treef8ada4659f2b650c2e56abbaa31ea4eaf79c30fb
parent51aba2ad789bf5efc340ff686dcfee7aeb6fd873 (diff)
downloadfarside-5235f5a3bf620a787d0d2ee0021336c893ffa013.tar.gz
Replace `poison` dependency w/ `jason`
The dependency took a long time to compile, and was causing problems for a user who was attempting to build the project. Since it wasn't a strictly necessary dependency, and `jason` was already included in the project, all instances of `poison` have been replaced with `jason`. The only additional code that this introduced was converting from generic maps returned by `Jason.decode` into Service structs.
-rw-r--r--lib/farside/instances.ex10
-rw-r--r--mix.exs1
-rw-r--r--test/farside_test.exs2
3 files changed, 9 insertions, 4 deletions
diff --git a/lib/farside/instances.ex b/lib/farside/instances.ex
index 7a07827..625bbb4 100644
--- a/lib/farside/instances.ex
+++ b/lib/farside/instances.ex
@@ -43,10 +43,16 @@ defmodule Farside.Instances do
def update() do
{:ok, file} = File.read(@services_json)
- {:ok, json} = Poison.decode(file, as: [%Service{}])
+ {:ok, json} = Jason.decode(file)
# Loop through all instances and check each for availability
- for service <- json do
+ for service_json <- json do
+ service_atom = for {key, val} <- service_json, into: %{} do
+ {String.to_existing_atom(key), val}
+ end
+
+ service = struct(%Service{}, service_atom)
+
IO.puts("#{@debug_header}#{service.type}")
result =
diff --git a/mix.exs b/mix.exs
index 229987e..80cc121 100644
--- a/mix.exs
+++ b/mix.exs
@@ -26,7 +26,6 @@ defmodule Farside.MixProject do
{:jason, "~> 1.1"},
{:plug_attack, "~> 0.4.2"},
{:plug_cowboy, "~> 2.0"},
- {:poison, "~> 5.0"},
{:quantum, "~> 3.0"},
{:redix, "~> 1.1"}
]
diff --git a/test/farside_test.exs b/test/farside_test.exs
index d508b27..ff7ac35 100644
--- a/test/farside_test.exs
+++ b/test/farside_test.exs
@@ -45,7 +45,7 @@ defmodule FarsideTest do
test "/:service" do
{:ok, file} = File.read(@services_json)
- {:ok, service_list} = Poison.decode(file, as: [%{}])
+ {:ok, service_list} = Jason.decode(file)
service_names =
Enum.map(