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

org.openmbee.mms.twc.utilities.JsonUtils Maven / Gradle / Ivy

package org.openmbee.mms.twc.utilities;

import org.json.JSONArray;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;



@Component
public class JsonUtils {

	public JSONArray parseStringToJsonArray(String restResponse) {
		JSONArray jsonArr = null;

		jsonArr = new JSONArray(restResponse);
		if (jsonArr.length() == 0) {
			return null;
		}
		return jsonArr;
	}

	public List convertJsonArrayToStringArray(JSONArray jsonArray) {

		if (jsonArray == null)
			return null;

		List strList = new ArrayList();

		for (int inx = 0; inx < jsonArray.length(); inx++) {
			strList.add(jsonArray.getString(inx));
		}
		return strList;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy