Java Code Examples for com.alibaba.fastjson.JSONArray#set()

The following examples show how to use com.alibaba.fastjson.JSONArray#set() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RequestBodyDecryptWrapper.java    From SuperBoot with MIT License 6 votes vote down vote up
/**
 * 解密JSON数组对象
 *
 * @param secretKey 密钥
 * @param jsonArray JSON数组
 * @return
 */
public JSONArray aesJsonArray(String secretKey, JSONArray jsonArray) {
    for (int i = 0; i < jsonArray.size(); i++) {
        //判断是否为JSON对象
        if (jsonArray.get(i) instanceof JSONObject) {
            JSONObject jsonObject = jsonArray.getJSONObject(i);
            //变更JSON数组对象
            jsonArray.set(i, aesJsonObject(secretKey, jsonObject));
        } else {
            //非JSON对象直接执行解密
            jsonArray.set(i, aesDecrypt(secretKey, jsonArray.getString(i)));
        }

    }
    return jsonArray;
}