mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-12-12 02:35:42 +00:00
20 lines
343 B
Elixir
20 lines
343 B
Elixir
defmodule WandererApp.Utils.JSONUtil do
|
|
@moduledoc false
|
|
|
|
def read_json(filename) do
|
|
{:ok, body} = File.read(filename)
|
|
Jason.decode(body)
|
|
end
|
|
|
|
def map_json({:ok, json}, mapper) do
|
|
Enum.map(json, mapper)
|
|
end
|
|
|
|
def compress(data) do
|
|
data
|
|
|> Jason.encode!()
|
|
|> :zlib.compress()
|
|
|> Base.encode64()
|
|
end
|
|
end
|