Skip to content

Instantly share code, notes, and snippets.

@dfcarpenter
Last active January 15, 2016 21:13
Show Gist options
  • Save dfcarpenter/fcd648c23187d9eb5fa3 to your computer and use it in GitHub Desktop.
Save dfcarpenter/fcd648c23187d9eb5fa3 to your computer and use it in GitHub Desktop.
Elixir service
Users.newusers
|> elem(1)
|> Map.get("Items")
|> Poison.encode
|> elem(1)
|> File.write("/dir/users.json")
#response from dynamodb after first function
{:ok,
%{"Count" => 691,
"Items" => [%{"accountStatus" => %{"S" => "active"},
"createdDate" => %{"N" => "1452199374896"},
"emailAddress" => %{"S" => "test@email.com"},
"fullName" => %{"S" => "Tim Madams"},
"userId" => %{"S" => "b0aaa703093deeb4b68275a801db5940"}},
%{"accountStatus" => %{"S" => "active"},
"createdDate" => %{"N" => "1452203121748"},
"emailAddress" => %{"S" => "test@email.com"},
"fullName" => %{"S" => "kc"},
"userId" => %{"S" => "3dc9b67a039c4af061cfd9b505cd5bcf"}},
%{"accountStatus" => %{"S" => "active"},
"createdDate" => %{"N" => "1452204318593"},
"emailAddress" => %{"S" => "test@email.com"},
"fullName" => %{"S" => "Fernando"},
"userId" => %{"S" => "91e63f80a8d7e9cb4692d1b26bce7cfd"}},
%{"accountStatus" => %{"S" => "active"},
"createdDate" => %{"N" => "1452208426812"},
"emailAddress" => %{"S" => "test@email.com"}}]}}
@bryanjos
Copy link

This should work. You are currently piping the json in as the first argument of File.write and it's trying to use the json as the file name

     json = Users.newusers
     |> elem(1)
     |> Map.get("Items")
     |> Poison.encode 
     |> elem(1)


     File.write("/dir/users.json", json)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment