0
私はerlangオブジェクトの完全なタプルを、後でJSONに変換する予定のマップに変換しています。このリストは空で表示されますが、タプルは正しく解析されます。
tileJSON関数が2要素タプルで呼び出されています。私は、それぞれのtableCache要素のためにマップ内にタイルを含む行のリストを見ることを期待しています。代わりに、私はこれを参照してください。
#{"availableTablePids" => ["<0.477.0>"],
"hall" => [],
"tableCache" => [],
"tablePids" => ["<0.477.0>"]}
このようなタプルを返すようにtileJSONの設定:
tileJSON({Status, Sitter}) ->
{atomJSON(Status), atomJSON(Sitter)}.
私はこのデータを取得する:
#{"availableTablePids" => ["<0.477.0>"],
"hall" => [],
"tableCache" => [#{"actions" => #{"current" => "x","o" => #{"next" => 0,"now" => 0},"x" => #{"next" => 0,"now" => 2}},
"board" => [[{"spawn","x"},
{"empty","null"},
{"empty","null"},
{"empty","null"},
{"empty","null"}],
[{"empty","null"},
{"empty","null"},
{"empty","null"},
{"ridge","null"},
{"empty","null"}],
[{"empty","null"},
{"empty","null"},
{"ridge","null"},
{"empty","null"},
{"empty","null"}],
[{"empty","null"},
{"ridge","null"},
{"empty","null"},
{"empty","null"},
{"empty","null"}],
[{"empty","null"},
{"empty","null"},
{"empty","null"},
{"empty","null"},
{"spawn","o"}]],
"clock" => #{"current" => "x","o" => 3000,"status" => "unstarted","x" => 3000}}],
"tablePids" => ["<0.477.0>"]}
atomJSON(Atom) -> atom_to_list(Atom).
tileJSON({Status, Sitter}) ->
[atomJSON(Status), atomJSON(Sitter)].
rowJSON(Row) ->
lists:map(fun(Tile) -> tileJSON(Tile) end, Row).
boardJSON(Board) ->
lists:map(fun(Row) -> rowJSON(Row) end, Board).
tableCacheJSON(Cache) ->
lists:map(fun(#{actions := Actions, clock := Clock, board := Board}) ->
#{"actions" => actionsJSON(Actions),
"clock" => clockJSON(Clock),
"board" => boardJSON(Board)
}
end, Cache).
プログラムがクラッシュしていません。オリジナルのtileJSON関数の何が問題ですか?
すべてを再起動して動作します。ありがとうございました – quantumpotato