package com.eactive.eai.adapter.db.sql;

import org.json.simple.JSONObject;

import java.util.LinkedHashMap;

public class ResultParser {
	public static String toJsonString(LinkedHashMap<String, Object> map) {
		JSONObject jsonObject = new JSONObject();
	    for (String key : map.keySet()) {
	        jsonObject.put(key, map.get(key));
	    }
		return jsonObject.toJSONString();
	}
	
	public static String toXmlString(LinkedHashMap<String, Object> map) {
		StringBuilder sb = new StringBuilder();
		sb.append("<row>");
	    for (String key : map.keySet()) {
	        sb.append("<").append(key).append(">");
	        sb.append(map.get(key));
	        sb.append("</").append(key).append(">");
	    }
	    sb.append("</row>");
		return sb.toString();
	}
}
