Hello everyone,
I’m trying to parse this return to json in the phoenix.
%{"statuses_url" => "https://api.github.com/repos/sproutapp/pavlov/statuses/{sha}",
"git_refs_url" => "https://api.github.com/repos/sproutapp/pavlov/git/refs{/sha}",
"issue_comment_url" => "https://api.github.com/repos/sproutapp/pavlov/issues/comments{/number}",
"watchers" => 128, "mirror_url" => nil,
"languages_url" => "https://api.github.com/repos/sproutapp/pavlov/languages",
"stargazers_count" => 128,
"license" => %{"key" => "mit", "name" => "MIT License",
"node_id" => "MDc6TGljZW5zZTEz", "spdx_id" => "MIT",
"url" => "https://api.github.com/licenses/mit"}, "forks" => 6,
"default_branch" => "master",
"comments_url" => "https://api.github.com/repos/sproutapp/pavlov/comments{/number}",
"commits_url" => "https://api.github.com/repos/sproutapp/pavlov/commits{/sha}",
"id" => 27221358,
"clone_url" => "https://github.com/sproutapp/pavlov.git",
"homepage" => nil,
"stargazers_url" => "https://api.github.com/repos/sproutapp/pavlov/stargazers",
"events_url" => "https://api.github.com/repos/sproutapp/pavlov/events",
...},
%{"statuses_url" => "https://api.github.com/repos/jonasschmidt/ex_json_schema/statuses/{sha}",
"git_refs_url" => "https://api.github.com/repos/jonasschmidt/ex_json_schema/git/refs{/sha}",
"issue_comment_url" => "https://api.github.com/repos/jonasschmidt/ex_json_schema/issues/comments{/number}",
"watchers" => 127, "mirror_url" => nil,
"languages_url" => "https://api.github.com/repos/jonasschmidt/ex_json_schema/languages",
"stargazers_count" => 127,
"license" => %{"key" => "mit", "name" => "MIT License",
"node_id" => "MDc6TGljZW5zZTEz", "spdx_id" => "MIT",
"url" => "https://api.github.com/licenses/mit"}, "forks" => 34,
"default_branch" => "master",
"comments_url" => "https://api.github.com/repos/jonasschmidt/ex_json_schema/comments{/number}",
"commits_url" => "https://api.github.com/repos/jonasschmidt/ex_json_schema/commits{/sha}",
"id" => 36134727,
"clone_url" => "https://github.com/jonasschmidt/ex_json_schema.git",
"homepage" => "",
"stargazers_url" => "https://api.github.com/repos/jonasschmidt/ex_json_schema/stargazers",
...},
But without success, can anyone help?
I tried that way …
def index(conn, _params) do
repos = Githubapp.search_repo("elixir-lang language:elixir")
repos
|> Enum.map(&Enum.zip(repos, &1))
|> Enum.map(&Enum.into(&1, %{}))
render conn, "index.json", repos: repos
end
defmodule GithubappWeb.PageView do
use GithubappWeb, :view
def render("index.json", %{repos: repos}) do
%{data: render_many(repos, GithubappWeb.PageView, "repo.json")}
end
def render("repo.json", repos) do
%{data: repos}
end
end
Thank you all!