From 5235f5a3bf620a787d0d2ee0021336c893ffa013 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Mon, 14 Feb 2022 11:21:32 -0700 Subject: 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. --- lib/farside/instances.ex | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib') 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 = -- cgit v1.2.3