LoginSignup
1
1

More than 1 year has passed since last update.

wslでelixir その18

Last updated at Posted at 2023-01-13

概要

wsl(wsl2じゃない)で、elixirやってみた。
パッケージマネージャ?、mix deps.get使ってみた。
jsonパーサー、jason使ってみた。

mix deps.get

mix.exsいじる。

  defp deps do
    [
      # {:dep_from_hexpm, "~> 0.3.0"},
      # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
		{:jason, "~> 1.2"}
    ]
  end

実行

$ mix deps.get
Resolving Hex dependencies...
Resolution completed in 0.532s
New:
  jason 1.4.0
* Getting jason (Hex package)

jasonを実行

$ iex -S mix
Erlang/OTP 25 [erts-13.0.4] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit:ns]

==> jason
Compiling 10 files (.ex)
Generated jason app
==> hello
Generated hello app
Interactive Elixir (1.13.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> %{"first" => 1, "last" => 10, "step" => 2}
%{"first" => 1, "last" => 10, "step" => 2}
iex(2)> |> Jason.encode!
"{\"first\":1,\"last\":10,\"step\":2}"
iex(3)> |> Jason.decode!(keys: :atoms)
%{first: 1, last: 10, step: 2}
iex(4)> %{first: 1, last: 10, step: 2}
%{first: 1, last: 10, step: 2}
iex(5)> |> Jason.encode!
"{\"first\":1,\"last\":10,\"step\":2}"
iex(6)> |> Jason.decode!
%{"first" => 1, "last" => 10, "step" => 2}
iex(7)>

以上。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1