Make export mochijson friendly
This commit is contained in:
parent
d8ca0274f6
commit
ed56ef17a1
1 changed files with 7 additions and 6 deletions
|
@ -121,7 +121,8 @@ new_tree(TreeID, Size) ->
|
||||||
export_tree(Tree) ->
|
export_tree(Tree) ->
|
||||||
L2 =
|
L2 =
|
||||||
lists:foldl(fun(X, L2Acc) ->
|
lists:foldl(fun(X, L2Acc) ->
|
||||||
[{X, array:get(X, Tree#tictactree.level2)}|L2Acc]
|
[{integer_to_binary(X),
|
||||||
|
array:get(X, Tree#tictactree.level2)}|L2Acc]
|
||||||
end,
|
end,
|
||||||
[],
|
[],
|
||||||
lists:seq(0, Tree#tictactree.width - 1)),
|
lists:seq(0, Tree#tictactree.width - 1)),
|
||||||
|
@ -146,11 +147,11 @@ import_tree(ExportedTree) ->
|
||||||
{Size, Width} = lists:keyfind(Width, 2, Sizes),
|
{Size, Width} = lists:keyfind(Width, 2, Sizes),
|
||||||
{BitWidth, Width, SegmentCount} = get_size(Size),
|
{BitWidth, Width, SegmentCount} = get_size(Size),
|
||||||
Lv2Init = array:new([{size, Width}]),
|
Lv2Init = array:new([{size, Width}]),
|
||||||
Lv2 = lists:foldl(fun({X, L2SegBin}, L2Array) ->
|
FoldFun =
|
||||||
array:set(X, L2SegBin, L2Array)
|
fun({X, L2SegBin}, L2Array) ->
|
||||||
|
array:set(binary_to_integer(X), L2SegBin, L2Array)
|
||||||
end,
|
end,
|
||||||
Lv2Init,
|
Lv2 = lists:foldl(FoldFun, Lv2Init, L2List),
|
||||||
L2List),
|
|
||||||
#tictactree{treeID = import,
|
#tictactree{treeID = import,
|
||||||
size = Size,
|
size = Size,
|
||||||
width = Width,
|
width = Width,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue