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

com.aliyun.openservices.eas.predict.request.JsonRequest Maven / Gradle / Ivy

package com.aliyun.openservices.eas.predict.request;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;

public class JsonRequest {
	private List> inputs = new ArrayList>();

	public List> getInputs() {
		return inputs;
	}

	public String getJSON() throws JSONException, IOException {
		ArrayList inputJsonList = new ArrayList();
		for(Map input : inputs) {
			JSONObject item = new JSONObject();
			for (Map.Entry entry : input.entrySet()) {
				item.put(entry.getKey(), entry.getValue());
			}
			inputJsonList.add(item);
		}
		JSONObject input = new JSONObject();
		input.put("inputs", inputJsonList);
		return JSON.toJSONString(input);
	}
	
	public void setInputs(List> inputs) {
		this.inputs = inputs;
	}
	
	public Map addRow() {
		Map newMap = new HashMap();
		inputs.add(newMap);
		return newMap;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy