All Downloads are FREE. Search and download functionalities are using the official Maven repository.

test.JSheet.TestSheet Maven / Gradle / Ivy

There is a newer version: 1.0.3
Show newest version
package test.JSheet;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;

import com.github.opendevl.JFlat;

/**
 * @author aptus
 * Yahoo
 */
public class TestSheet {
	/**
	 * Just for testing
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException{
		
		
		String str = new String(Files.readAllBytes(Paths.get("/home/workspace/mvgitproj/Json2Flat/json2flat/src/main/resources/test.json")));
		JFlat flatMe = new JFlat(str);
		
		List json2csv = flatMe.json2Sheet().getJsonAsSheet();
		
		flatMe.write2csv("/home/Desktop/json2csv.csv");
		/*PrintWriter writer = new PrintWriter("/home/aptus/Desktop/json2csv.csv", "UTF-8");
		boolean comma = false;
		for(Object[] o : json2csv){
			comma = false;
			for(Object t : o){
				if(t==null){
					writer.print(comma == true ? "," : "");
				}
				else{
					writer.print(comma == true ? ","+t.toString() : t.toString());
				}
				if(comma == false)
					comma = true;
			}
			writer.println();
		}
		writer.close();*/
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy