<commit_before>-module(boss_json).
-export([encode/2]).

encode([First|_] = Data, ModelList) ->
    case boss_record_lib:is_boss_record(First, ModelList) of
        true ->
            mochijson2:encode(lists:map(fun boss_record_to_json/1, Data));
        false ->
            mochijson2:encode(json_data1(Data, ModelList, []))
    end.

encode([],_) ->
    "".

json_data1([], _, Acc) ->
    {struct, lists:reverse(Acc)};
json_data1([{VariableName, [First|_] = Variable}|Rest], ModelList, Acc) when is_integer(First) ->
    json_data1(Rest, ModelList, [{VariableName, list_to_binary(Variable)}|Acc]);
json_data1([{VariableName, [First|_] = Variable}|Rest], ModelList, Acc) when is_tuple(First) ->
    case boss_record_lib:is_boss_record(First, ModelList) of
        true ->
            json_data1(Rest, ModelList, [{VariableName, lists:map(fun boss_record_to_json/1, Variable)}|Acc]);
        false ->
            json_data1(Rest, ModelList, [{VariableName, json_data1(Variable, ModelList, [])}|Acc])
    end;
json_data1([{VariableName, [First|_] = Variable}|Rest], ModelList, Acc) when is_list(First) ->
    json_data1(Rest, ModelList, [{VariableName, lists:map(fun(Item) -> 
                            json_data1(Item, ModelList, [])
                    end, Variable)}|Acc]);
json_data1([{VariableName, {A, B, C} = Val}|Rest], ModelList, Acc) when is_integer(A), is_integer(B), is_integer(C) ->
    json_data1(Rest, ModelList, [{VariableName, list_to_binary(erlydtl_filters:date(calendar:now_to_datetime(Val), "F d, Y H:i:s"))}|Acc]);
json_data1([{VariableName, Variable}|Rest], ModelList, Acc) ->
    case boss_record_lib:is_boss_record(Variable, ModelList) of
        true -> 
            json_data1(Rest, ModelList, [{VariableName, boss_record_to_json(Variable)}|Acc]);
        false -> 
            json_data1(Rest, ModelList, [{VariableName, Variable}|Acc])<commit_msg>Opps, syntax (smacks face)<commit_after>-module(boss_json).
-export([encode/2]).

encode([First|_] = Data, ModelList) ->
    case boss_record_lib:is_boss_record(First, ModelList) of
        true ->
            mochijson2:encode(lists:map(fun boss_record_to_json/1, Data));
        false ->
            mochijson2:encode(json_data1(Data, ModelList, []))
    end;

encode([],_) ->
    "".

json_data1([], _, Acc) ->
    {struct, lists:reverse(Acc)};
json_data1([{VariableName, [First|_] = Variable}|Rest], ModelList, Acc) when is_integer(First) ->
    json_data1(Rest, ModelList, [{VariableName, list_to_binary(Variable)}|Acc]);
json_data1([{VariableName, [First|_] = Variable}|Rest], ModelList, Acc) when is_tuple(First) ->
    case boss_record_lib:is_boss_record(First, ModelList) of
        true ->
            json_data1(Rest, ModelList, [{VariableName, lists:map(fun boss_record_to_json/1, Variable)}|Acc]);
        false ->
            json_data1(Rest, ModelList, [{VariableName, json_data1(Variable, ModelList, [])}|Acc])
    end;
json_data1([{VariableName, [First|_] = Variable}|Rest], ModelList, Acc) when is_list(First) ->
    json_data1(Rest, ModelList, [{VariableName, lists:map(fun(Item) -> 
                            json_data1(Item, ModelList, [])
                    end, Variable)}|Acc]);
json_data1([{VariableName, {A, B, C} = Val}|Rest], ModelList, Acc) when is_integer(A), is_integer(B), is_integer(C) ->
    json_data1(Rest, ModelList, [{VariableName, list_to_binary(erlydtl_filters:date(calendar:now_to_datetime(Val), "F d, Y H:i:s"))}|Acc]);
json_data1([{VariableName, Variable}|Rest], ModelList, Acc) ->
    case boss_record_lib:is_boss_record(Variable, ModelList) of
        true -> 
            json_data1(Rest, ModelList, [{VariableName, boss_record_to_json(Variable)}|Acc]);
        false -> 
            json_data1(Rest, ModelList, [{VariableName, Variable}|Acc])
{'fraction_non_alphanumeric': 0.16043489790506496, 'fraction_numerical': 0.011137629276054098, 'mean_word_length': 4.049531459170013, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5777463', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1265, 'n_words': 224}