當前位置: 首頁>>代碼示例>>Java>>正文


Java JSONArray.toArray方法代碼示例

本文整理匯總了Java中net.sf.json.JSONArray.toArray方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONArray.toArray方法的具體用法?Java JSONArray.toArray怎麽用?Java JSONArray.toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.sf.json.JSONArray的用法示例。


在下文中一共展示了JSONArray.toArray方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: jsonArrayToBeanArray

import net.sf.json.JSONArray; //導入方法依賴的package包/類
/**
 * Converts the input array JSON structure into an array of instances of the
 * beanClassName. If the beanClassName is null, then an arrays of instances
 * of org.apache.commons.beanutils.DynaBean will be returned.
 *
 * @param input
 *            input array as a JSON structure.
 * @param beanClassName
 *            the name of the bean class.
 * @return the input array JSON structure as an array of instances of the beanClassName.
 * @throws ClassNotFoundException if the beanClassName is invalid.
 */
public static Object[] jsonArrayToBeanArray(String input, String beanClassName) throws ClassNotFoundException {
    if (log.isDebugEnabled())
        log.debug("Converting JSON '" + input + "' into an array of instances of " + beanClassName);
    registerCustomMorphers();
    Class beanClass = beanClassName != null ? Class.forName(beanClassName) : null;
    JSONArray jsonArray = JSONArray.fromObject(input);
    Object[] beans = beanClass != null ? (Object[]) JSONArray.toArray(jsonArray, beanClass) : (Object[]) JSONArray.toArray(jsonArray);
    if (log.isDebugEnabled())
        log.debug("Converted to: " + Arrays.toString(beans));
    return beans;
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:24,代碼來源:ExcelExportService.java

示例2: jsonArrayToBeanArray

import net.sf.json.JSONArray; //導入方法依賴的package包/類
/**
 * Converts the input array JSON structure into an array of instances of the
 * beanClassName. If the beanClassName is null, then an arrays of instances
 * of org.apache.commons.beanutils.DynaBean will be returned.
 * 
 * @param input
 *            input array as a JSON structure.
 * @param beanClassName
 *            the name of the bean class.
 * @return the input array JSON structure as an array of instances of the beanClassName.
 * @throws ClassNotFoundException if the beanClassName is invalid.
 */
public static Object[] jsonArrayToBeanArray(String input, String beanClassName) throws ClassNotFoundException {
    if (log.isDebugEnabled())
        log.debug("Converting JSON '" + input + "' into an array of instances of " + beanClassName);
    registerCustomMorphers();
    Class beanClass = beanClassName != null ? Class.forName(beanClassName) : null;
    JSONArray jsonArray = JSONArray.fromObject(input);
    Object[] beans = beanClass != null ? (Object[]) JSONArray.toArray(jsonArray, beanClass) : (Object[]) JSONArray.toArray(jsonArray);
    if (log.isDebugEnabled())
        log.debug("Converted to: " + Arrays.toString(beans));
    return beans;
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:24,代碼來源:ExcelExportService.java

示例3: getObjectArrayFromJson

import net.sf.json.JSONArray; //導入方法依賴的package包/類
/**
 * 從json數組中得到相應java數組 json形如:["123", "456"]
 * 
 * @param jsonString
 * @return
 */
public static Object[] getObjectArrayFromJson(String jsonString) {
	JSONArray jsonArray = JSONArray.fromObject(jsonString);
	return jsonArray.toArray();
}
 
開發者ID:jiangzongyao,項目名稱:kettle_support_kettle8.0,代碼行數:11,代碼來源:JSONUtil.java


注:本文中的net.sf.json.JSONArray.toArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。