本文整理匯總了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;
}
示例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;
}
示例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();
}