package com.github.TKnudsen.timeseries.operations.io.json;

import java.io.File;
import java.io.IOException;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.TKnudsen.timeseries.data.univariate.ITimeSeriesUnivariate;

/**
 * <p>
 * Title: JSONWriter
 * </p>
 * 
 * <p>
 * Description: stores time series objects as JSON
 * </p>
 * 
 * <p>
 * Copyright: Copyright (c) 2017
 * </p>
 * 
 * @author Juergen Bernard
 * @version 1.0
 */
public class JSONWriter {

	public static String writeToString(ITimeSeriesUnivariate ts) {
		ObjectMapper mapper = new ObjectMapper();
		mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);

		String writeValueAsString;
		try {
			writeValueAsString = mapper.writeValueAsString(ts);
			return writeValueAsString;
		} catch (JsonProcessingException e) {
			e.printStackTrace();
		}
		return null;
	}

	public static void writeToFile(ITimeSeriesUnivariate ts, String file) {
		ObjectMapper mapper = new ObjectMapper();
		mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);

		try {
			mapper.writeValue(new File(file), ts);
		} catch (IOException e) {
			e.printStackTrace();
		}

		return;
	}
}

@@ -221,16 +221,77 @@
 apper;%0D%0A
+import com.fasterxml.jackson.databind.SerializationFeature;%0D%0A
 import c
@@ -360,16 +360,16 @@
 riate;%0D%0A
-
 %0D%0A/**%0D%0A 
@@ -794,24 +794,87 @@
 NON_FINAL);%0D
+%0A%09%09mapper.configure(SerializationFeature.INDENT_OUTPUT, true);%0D
 %0A%0D%0A%09%09String 
@@ -1194,32 +1194,32 @@
 bjectMapper();%0D%0A
-
 %09%09mapper.enableD
@@ -1270,16 +1270,79 @@
 FINAL);%0D
+%0A%09%09mapper.configure(SerializationFeature.INDENT_OUTPUT, true);%0D
 %0A%0D%0A%09%09try

JSON io: SerializationFeature.INDENT_OUTPUT,true