Add struct to help with mochijson2
Try and make this more mochijson2 friendly
This commit is contained in:
parent
9f97c82d0d
commit
d98534b8f3
1 changed files with 8 additions and 2 deletions
|
@ -124,13 +124,19 @@ export_tree(Tree) ->
|
||||||
end,
|
end,
|
||||||
[],
|
[],
|
||||||
lists:seq(0, Tree#tictactree.width - 1)),
|
lists:seq(0, Tree#tictactree.width - 1)),
|
||||||
[{level1, Tree#tictactree.level1}, {level2, lists:reverse(L2)}].
|
{struct,
|
||||||
|
[{<<"level1">>, base64:encode_to_string(Tree#tictactree.level1)},
|
||||||
|
{<<"level2">>, {struct, lists:reverse(L2)}}
|
||||||
|
]}.
|
||||||
|
|
||||||
-spec import_tree(list()) -> tictactree().
|
-spec import_tree(list()) -> tictactree().
|
||||||
%% @doc
|
%% @doc
|
||||||
%% Reverse the export process
|
%% Reverse the export process
|
||||||
import_tree(ExportedTree) ->
|
import_tree(ExportedTree) ->
|
||||||
[{level1, L1Bin}, {level2, L2List}] = ExportedTree,
|
{struct,
|
||||||
|
[{<<"level1">>, L1Base64},
|
||||||
|
{<<"level2">>, {struct, L2List}}]} = ExportedTree,
|
||||||
|
L1Bin = base64:decode(L1Base64),
|
||||||
Sizes = [{small, element(2, ?SMALL)},
|
Sizes = [{small, element(2, ?SMALL)},
|
||||||
{medium, element(2, ?MEDIUM)},
|
{medium, element(2, ?MEDIUM)},
|
||||||
{large, element(2, ?LARGE)},
|
{large, element(2, ?LARGE)},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue