当前位置: 首页>>代码示例>>Java>>正文


Java JSONException类代码示例

本文整理汇总了Java中com.liferay.portal.kernel.json.JSONException的典型用法代码示例。如果您正苦于以下问题:Java JSONException类的具体用法?Java JSONException怎么用?Java JSONException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JSONException类属于com.liferay.portal.kernel.json包,在下文中一共展示了JSONException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseJSONObject

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
protected List<Object[]> parseJSONObject(
    List<Object[]> keyValues, JSONArray jsonArray)
    throws JSONException {

    if (jsonArray != null && jsonArray.length() > 0) {
        for (int i = 0; i < jsonArray.length(); i++) {
            Object tempObject = jsonArray.get(i);
            if (tempObject instanceof JSONObject) {
                parseJSONObject(keyValues, (JSONObject) tempObject);
            }
            else if (tempObject instanceof JSONArray) {
                parseJSONObject(keyValues, (JSONArray) tempObject);
            }
            else {
                // Tinh chung cho key cha.
            }
        }
    }

    return keyValues;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:22,代码来源:RegistrationFormIndexer.java

示例2: parseJSONObject

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
/**
 * @param keyValues
 * @param jsonArray
 * @return
 * @throws JSONException
 */
protected List<Object[]> parseJSONObject(List<Object[]> keyValues,
		JSONArray jsonArray) throws JSONException {
	if (jsonArray != null && jsonArray.length() > 0) {
		for (int i = 0; i < jsonArray.length(); i++) {
			Object tempObject = jsonArray.get(i);
			if (tempObject instanceof JSONObject) {
				parseJSONObject(keyValues, (JSONObject) tempObject);
			} else if (tempObject instanceof JSONArray) {
				parseJSONObject(keyValues, (JSONArray) tempObject);
			} else {
				// Tinh chung cho key cha.
			}
		}
	}

	return keyValues;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:24,代码来源:DeliverableIndexer.java

示例3: updateOfficeSitePreferencesByKey

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
@Override
public OfficeSite updateOfficeSitePreferencesByKey(long userId, long companyId, long groupId, long id, String key,
		String value, ServiceContext serviceContext)
		throws NoSuchUserException, NotFoundException, UnauthenticationException, UnauthorizationException {
	OfficeSite officeSite = OfficeSiteLocalServiceUtil.fetchOfficeSite(id);

	try {
		JSONObject jsonObject = JSONFactoryUtil.createJSONObject(officeSite.getPreferences());
		
		jsonObject.put(key, value);
		
		officeSite = OfficeSiteLocalServiceUtil.updateOfficeSite(userId, officeSite.getOfficeSiteId(), officeSite.getName(),
				officeSite.getEnName(), officeSite.getGovAgencyCode(), officeSite.getAddress(), officeSite.getTelNo(),
				officeSite.getFaxNo(), officeSite.getEmail(), officeSite.getWebsite(), officeSite.getLogoFileEntryId(),
				officeSite.getSiteGroupId(), officeSite.getAdminUserId(), jsonObject.toJSONString(), serviceContext);
		
		
	} catch (JSONException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

	return officeSite;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:25,代码来源:OfficeSiteActions.java

示例4: getPreferenceByKey

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
@Override
public String getPreferenceByKey(long id, long groupId, String key, ServiceContext serviceContext) {
	Preferences preferences = PreferencesLocalServiceUtil.fetchByF_userId(groupId, id);
	String result = StringPool.BLANK;
	try {
		
		JSONObject jsonObject = JSONFactoryUtil.createJSONObject(preferences.getPreferences());
		
		result = jsonObject.getString(key);
		
	} catch (JSONException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	return result;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:18,代码来源:UserActions.java

示例5: updatePreferences

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
@Override
public String updatePreferences(long id, long groupId, String key, String value, ServiceContext serviceContext)
		throws NoSuchUserException, NotFoundException, UnauthenticationException, UnauthorizationException, DuplicateCategoryException {
	Preferences preferences = PreferencesLocalServiceUtil.fetchByF_userId(groupId, id);
	
	JSONObject jsonObject;
	try {
		jsonObject = JSONFactoryUtil.createJSONObject(preferences.getPreferences());
		
		jsonObject.put(key, value);
		
		preferences = PreferencesLocalServiceUtil.updatePreferences(id, preferences.getPreferencesId(), jsonObject.toJSONString(), serviceContext);
		
	} catch (JSONException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	
	return preferences.getPreferences();
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:22,代码来源:UserActions.java

示例6: setTypeParam

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
/**
 * Set types (asset types to search for).
 * 
 * @throws ClassNotFoundException
 * @throws PatternSyntaxException
 * @throws JSONException 
 */
protected void setTypeParam()
	throws PatternSyntaxException, ClassNotFoundException, JSONException {

	String typeFilter =
		ParamUtil.getString(_portletRequest, GSearchWebKeys.FILTER_TYPE);

	List<String> classNames = new ArrayList<String>();

	String className = parseAssetClass(typeFilter);

	if (className != null) {
		classNames.add(className);
	}
	else {
		classNames.addAll(parseDefaultAssetClasses());
	}

	_queryParams.setClassNames(classNames);
}
 
开发者ID:peerkar,项目名称:liferay-gsearch,代码行数:27,代码来源:QueryParamsBuilderImpl.java

示例7: setFacets

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void setFacets(SearchContext searchContext)
	throws JSONException {
	
	JSONArray configuration = JSONFactoryUtil.createJSONArray(_gSearchConfiguration.facetConfiguration());

	for (int i = 0; i < configuration.length(); i++) {

		JSONObject item = configuration.getJSONObject(i);

		String fieldName = item.getString("fieldName");
		
		Facet facet = new MultiValueFacet(searchContext);
		facet.setFieldName(fieldName);
		facet.setStatic(false);

		searchContext.addFacet(facet);
	}
}
 
开发者ID:peerkar,项目名称:liferay-gsearch,代码行数:23,代码来源:FacetsBuilderImpl.java

示例8: jsonToMap

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
public static Map<String, Object> jsonToMap(JSONObject json) {
	Map<String, Object> retMap = new HashMap<String, Object>();

	if (Validator.isNotNull(json)) {
		try {
			retMap = toMap(json);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	return retMap;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:14,代码来源:DossierFileListenner.java

示例9: toList

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
public static List<Object> toList(JSONArray array) throws JSONException {
	List<Object> list = new ArrayList<Object>();
	for (int i = 0; i < array.length(); i++) {
		Object value = array.getJSONObject(i);

		if (value instanceof JSONObject) {
			value = toMap((JSONObject) value);
		}
		list.add(value);
	}
	return list;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:13,代码来源:DossierFileListenner.java

示例10: jsonToMap

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
private Map<String, Object> jsonToMap(JSONObject json) {
	Map<String, Object> retMap = new HashMap<String, Object>();

	if (Validator.isNotNull(json)) {
		try {
			retMap = toMap(json);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	return retMap;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:14,代码来源:DossierFileLocalServiceImpl.java

示例11: createFromJSON

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
public static Configuracao createFromJSON(String json) throws JSONException {
	JSONObject jsonObj = JSONFactoryUtil.createJSONObject(json);

	long comunidadeSelecionada = jsonObj.getLong("comunidadeSelecionada");
	int periodoEmDias = jsonObj.getInt("periodoEmDias");
	int qtdDeRecursos = jsonObj.getInt("qtdDeRecursos");
	int modoVisualizacao = jsonObj.getInt("modoVisualizacao");
	int recurso = jsonObj.getInt("recurso");

	return new Configuracao(comunidadeSelecionada, periodoEmDias, qtdDeRecursos, modoVisualizacao, recurso);
}
 
开发者ID:camaradosdeputadosoficial,项目名称:edemocracia,代码行数:12,代码来源:Configuracao.java

示例12: getConfiguracao

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
/**
 * Recupera as configurações do portlet
 * 
 * Se não encontrar retorna null
 * 
 * @return
 * @throws JSONException
 */
public static Configuracao getConfiguracao() throws JSONException {
	
	PortletPreferences portletPrefs = LiferayFacesContext.getInstance().getPortletPreferences();
	String json = portletPrefs.getValue(CONFIGURACAO_KEY, null);
	
	if (json != null) {
		return Configuracao.createFromJSON(json);
	} else {
		return null;
	}
	
}
 
开发者ID:camaradosdeputadosoficial,项目名称:edemocracia,代码行数:21,代码来源:ConfiguracaoManager.java

示例13: carregarConfiguracao

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
private void carregarConfiguracao() {
	try {
		Configuracao config = ConfiguracaoManager.getConfiguracao();
		if (config == null) {
			this.config = Configuracao.getConfiguracaoPadrao();
		} else {
			this.config = config;
		}
	} catch (JSONException e) {
		mostrarMensagemDeErro("Erro ao carregar configuração.");
		_log.error("Ocorreu um erro ao carregar configuracao.", e);
	}
}
 
开发者ID:camaradosdeputadosoficial,项目名称:edemocracia,代码行数:14,代码来源:ConfiguracaoBean.java

示例14: carregarConfiguracao

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
private void carregarConfiguracao() {
	
	try {
		config = ConfiguracaoManager.getConfiguracao();

	} catch (JSONException e) {
		mostrarMensagemDeErro("Erro ao recuperar dados.");
		_log.error("Erro ao recuperar dados.",e);
	}
	
}
 
开发者ID:camaradosdeputadosoficial,项目名称:edemocracia,代码行数:12,代码来源:InitBean.java

示例15: getPollerRequestDataMap

import com.liferay.portal.kernel.json.JSONException; //导入依赖的package包/类
private static Map<String, String> getPollerRequestDataMap(JSONObject dataJSON) throws JSONException {
	
	Map<String, String> dataMap = new HashMap<String, String>();
	
	Iterator<String> iterator = dataJSON.keys();
	while (iterator.hasNext()) {
		String key = iterator.next();
		dataMap.put(key, dataJSON.getString(key));
	}
	
	return dataMap;
}
 
开发者ID:saggiyogesh,项目名称:liferay-node-poller,代码行数:13,代码来源:PollerProcessorUtil.java


注:本文中的com.liferay.portal.kernel.json.JSONException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。