How do I use Jason instead of Poison?

I was very happy when I saw Jason to improved 30% the Json speed, but I didn’t find good document of Jason.

for example , my code was written with poison

def upload_drive_less_five(file, token) do
	    code = "Bearer #{token}"!(
	    	"", # url
	    	{:file, file},  # body
	    	[{"Authorization", code}],  # headers
	    	[timeout: 50_000, recv_timeout: 50_000] # options
	    |> IO.inspect


def refresh_token (email) do
	refresh_token =!(
      	"", # url
	    {:form, # body
	    	{"client_id", "#{System.get_env("GOOGLE_CLIENT_ID")}"} ,
	    	{"client_secret", "#{System.get_env("GOOGLE_CLIENT_SECRET")}"} ,
	    	{"refresh_token", "#{get_pass_refresh_token(email)}"},
	    	{"grant_type", "refresh_token"}
	    [{"Content-Type", "application/x-www-form-urlencoded"}] # headers
	|> Poison.decode

	{:ok, %{"access_token" => a_token}} = refresh_token

	update_token_after_refresh_token(email, a_token)

Now, What am I supposed to do in Jason?

1 Like

It seems like you’re confusing HTTPoison the HTTP client with Poison the json parsing/encoding package.

So |> Poison.decode would be |> Jason.decode in your second example, but that’s all that would change in your examples.