当前位置: 首页>>代码示例>>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;未经允许,请勿转载。