Search in sources :

Example 26 with JSONException

use of org.talend.utils.json.JSONException in project tbd-studio-se by Talend.

the class HDFSForm method initHadoopProperties.

private void initHadoopProperties() {
    String hadoopProperties = getConnection().getHadoopProperties();
    try {
        if (StringUtils.isNotEmpty(hadoopProperties)) {
            JSONArray jsonArr = new JSONArray(hadoopProperties);
            for (int i = 0; i < jsonArr.length(); i++) {
                HashMap<String, Object> map = new HashMap();
                JSONObject object = jsonArr.getJSONObject(i);
                Iterator it = object.keys();
                while (it.hasNext()) {
                    String key = (String) it.next();
                    map.put(key, object.get(key));
                }
                properties.add(map);
            }
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
Also used : JSONObject(org.talend.utils.json.JSONObject) HashMap(java.util.HashMap) JSONArray(org.talend.utils.json.JSONArray) Iterator(java.util.Iterator) JSONException(org.talend.utils.json.JSONException) JSONObject(org.talend.utils.json.JSONObject)

Aggregations

JSONException (org.talend.utils.json.JSONException)26 JSONObject (org.talend.utils.json.JSONObject)21 JSONArray (org.talend.utils.json.JSONArray)14 Project (org.talend.core.model.general.Project)6 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 PersistenceException (org.talend.commons.exception.PersistenceException)4 NoSQLConnection (org.talend.repository.model.nosql.NoSQLConnection)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 ConnectionBean (org.talend.core.model.general.ConnectionBean)3 EHadoopParamName (org.talend.metadata.managment.ui.utils.ExtendedNodeConnectionContextUtils.EHadoopParamName)3 Iterator (java.util.Iterator)2 SystemException (org.talend.commons.exception.SystemException)2 Context (org.talend.core.context.Context)2 RepositoryContext (org.talend.core.context.RepositoryContext)2 User (org.talend.core.model.properties.User)2 IConnParamName (org.talend.metadata.managment.ui.model.IConnParamName)2 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)2