<commit_before>

package helpers;

import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;

import models.Serializable;

public class Json {

	public static void main(String[] args) {
		
	}

	public static String jsonObject(String members) {
		return "{\n" + addTab(members) + "\n}";
	}
	
	public static String jsonMembers(String... members) {
		StringBuilder ret = new StringBuilder();
		for(int x = 0; x < members.length; ++x) {
			ret.append(members[x] + (x == members.length - 1 ? "" : ",\n"));
		}
		return ret.toString();
	}
	
	public static String jsonPair(String type, String value) {
		return "\"" + type + "\" : " + value;
	}

	public static String jsonArray(String elements) {
		return "[\n" + addTab(elements) + "\n]";
	}
	
	public static String jsonElements(String... elements) {
		StringBuilder ret = new StringBuilder();
		for(int x = 0; x < elements.length; ++x) {
			ret.append(elements[x] + (x == elements.length - 1 ? "" : ",\n"));
		}
		return ret.toString();
	}
	
	public static String jsonValue(String value) {
		return "\"" + value + "\"";
	}
	
	@SuppressWarnings("unchecked")
	public static String serializeArray(Object obj) {
    	LinkedList<String> list = new LinkedList<String>();
    	if(obj instanceof Stack) {
    		obj = ((Stack<Object>) obj).toArray();
    	}
    	else if(obj instanceof List) {
    		obj = ((List<Object>) obj).toArray();
    	}
    	
		Object[] arr =  (Object[]) obj;
		for(int x = 0; x < arr.length; ++x) {
			if(arr[x] instanceof Stack || arr[x] instanceof List || arr[x] instanceof Object[]) {
				list.add(serializeArray(arr[x]));
			}
			else {
				list.add(Json.jsonObject(((Serializable<Object>) arr[x]).serialize()));
			}
		}
    	return Json.jsonArray(Json.jsonElements(list.toArray((new String[list.size()]))));
    }
	
	private static String addTab(String str) {
		Scanner in = new Scanner(str); 
		StringBuilder ret = new StringBuilder();
		while(in.hasNextLine()) {
			ret.append("  " + in.nextLine());
		}
		in.close();
		return ret.toString();
	}
}<commit_msg>serializeArray bug<commit_after>

package helpers;

import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;

import models.Serializable;

public class Json {
	public static void main(String[] args) {
		
	}

	public static String jsonObject(String members) {
		return "{\n" + addTab(members) + "\n}";
	}
	
	public static String jsonMembers(String... members) {
		StringBuilder ret = new StringBuilder();
		for(int x = 0; x < members.length; ++x) {
			ret.append(members[x] + (x == members.length - 1 ? "" : ",\n"));
		}
		return ret.toString();
	}
	
	public static String jsonPair(String type, String value) {
		return "\"" + type + "\" : " + value;
	}

	public static String jsonArray(String elements) {
		return "[\n" + addTab(elements) + "\n]";
	}
	
	public static String jsonElements(String... elements) {
		StringBuilder ret = new StringBuilder();
		for(int x = 0; x < elements.length; ++x) {
			ret.append(elements[x] + (x == elements.length - 1 ? "" : ",\n"));
		}
		return ret.toString();
	}
	
	public static String jsonValue(String value) {
		return "\"" + value + "\"";
	}
	
	/**
	 * serializeArray supports: Lists, Stacks and Arrays. 
	 * These data structures can hold int, long, boolean, char
	 * String and Object(must implement Serializable)
	 * 
	 * @param obj
	 * @return String
	 */
	@SuppressWarnings("unchecked")
	public static String serializeArray(Object obj) {
    	LinkedList<String> list = new LinkedList<String>();
    	if(obj instanceof Stack) {
    		obj = ((Stack<Object>) obj).toArray();
    	}
    	else if(obj instanceof List) {
    		obj = ((List<Object>) obj).toArray();
    	}
    	if(obj instanceof int[]) {
			int[] arr = (int[]) obj;
			for(int x = 0; x < arr.length; ++x) 
				list.add(Json.jsonValue(arr[x] + ""));
		}
    	else if(obj instanceof boolean[]) {
			boolean[] arr = (boolean[]) obj;
			for(int x = 0; x < arr.length; ++x) 
				list.add(Json.jsonValue(arr[x] + ""));
		}
    	else if(obj instanceof long[]) {
			long[] arr = (long[]) obj;
			for(int x = 0; x < arr.length; ++x) 
				list.add(Json.jsonValue(arr[x] + ""));
		}
    	else if(obj instanceof char[]) {
			char[] arr = (char[]) obj;
			for(int x = 0; x < arr.length; ++x) 
				list.add(Json.jsonValue(arr[x] + ""));
		}
    	else if(obj instanceof String[]) {
			String[] arr = (String[]) obj;
			for(int x = 0; x < arr.length; ++x) 
				list.add(Json.jsonValue(arr[x] + ""));
    	}
    	
    	if(!(obj instanceof Object[]) || (obj instanceof String[]))
    		return Json.jsonArray(Json.jsonElements((String[]) list.toArray(new String[1])));
    		
		Object[] arr =  (Object[]) obj;
		for(int x = 0; x < arr.length; ++x) {
			if(arr[x] instanceof Stack || arr[x] instanceof List || arr[x] instanceof Object[]) {
				list.add(serializeArray(arr[x]));
			}
			else {
				list.add(Json.jsonObject(((Serializable<Object>) arr[x]).serialize()));
			}
		}
    	return Json.jsonArray(Json.jsonElements(list.toArray((new String[1]))));
    }
	
	private static String addTab(String str) {
		Scanner in = new Scanner(str); 
		StringBuilder ret = new StringBuilder();
		while(in.hasNextLine()) {
			ret.append("  " + in.nextLine());
		}
		in.close();
		return ret.toString();
	}
}
{'fraction_non_alphanumeric': 0.17430673457838144, 'fraction_numerical': 0.0032069420863987926, 'mean_word_length': 3.307067424857839, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 13, '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': '6162313', 'n_tokens_mistral': 1959, 'n_tokens_neox': 1780, 'n_words': 445}