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


Java JSONArray.iterator方法代码示例

本文整理汇总了Java中com.alibaba.fastjson.JSONArray.iterator方法的典型用法代码示例。如果您正苦于以下问题:Java JSONArray.iterator方法的具体用法?Java JSONArray.iterator怎么用?Java JSONArray.iterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.fastjson.JSONArray的用法示例。


在下文中一共展示了JSONArray.iterator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: login

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
@ApiOperation("用户登入")
@PostMapping("/login")
public ResponseEntity login(@RequestBody @Valid IndexLoginFormat format) {
    UserEntity userEntity = userService.getUserByLogin(format.getEmail(),
            new Md5Hash(format.getPassword()).toString());
    if (userEntity == null)
        throw new WebErrorException("用户名密码错误");

    JSONArray array = userEntity.getPermission();
    Iterator<Object> it = array.iterator();
    Set<String> permission = new HashSet<>();
    while (it.hasNext()) {
        permission.add(it.next().toString());
    }
    String token = JWTUtil.sign(userEntity.getUid(), userEntity.getRole(), permission, userEntity.getPassword());
    Cache<String, String> authCache = CacheController.getAuthCache();
    authCache.put(token, userEntity.getPassword());

    return new ResponseEntity("登入成功", token);
}
 
开发者ID:Eagle-OJ,项目名称:eagle-oj-api,代码行数:21,代码来源:IndexController.java

示例2: parseList

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
public static List<TagResult> parseList(String json) {
    JSONArray array = JSON.parseArray(json);
    List<TagResult> arrayList = new ArrayList<TagResult>(array.size());

    Iterator<Object> iterator = array.iterator();
    while (iterator.hasNext()) {
        JSONObject object = (JSONObject) iterator.next();
        Set<Entry<String, Object>> entrySet = object.entrySet();
        for (Entry<String, Object> entry : entrySet) {
            String key = entry.getKey();
            String value = entry.getValue().toString();
            TagResult tagResult = new TagResult(key, value);
            arrayList.add(tagResult);
            break;
        }
    }

    return arrayList;
}
 
开发者ID:aliyun,项目名称:HiTSDB-Client,代码行数:20,代码来源:TagResult.java

示例3: decodeSFSArray

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
private IArray decodeSFSArray(JSONArray jsa) {
    CArrayLite sfsArray = CArrayLite.newInstance();
    Iterator<Object> iter = jsa.iterator();

    while (iter.hasNext()) {
        Object value = iter.next();
        DataWrapper decodedObject = this.decodeJsonObject(value);
        if (decodedObject == null) {
            throw new IllegalStateException("(json2sfarray) Could not decode value for object: " + value);
        }

        sfsArray.add(decodedObject);
    }

    return sfsArray;
}
 
开发者ID:zerosoft,项目名称:CodeBroker,代码行数:17,代码来源:DefaultSFSDataSerializer.java

示例4: get

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
@Override
public NanoHTTPD.Response get(RouterNanoHTTPD.UriResource uriResource, Map<String, String> urlParams, NanoHTTPD.IHTTPSession session) {
    String sessionId = urlParams.get("sessionId");
    Map<String, String> body = new HashMap<String, String>();
    UiDevice mDevice = Elements.getGlobal().getmDevice();
    JSONObject result = null;
    try {
        session.parseBody(body);
        String postData = body.get("postData");
        JSONObject jsonObj = JSON.parseObject(postData);
        JSONArray keycodes = (JSONArray)jsonObj.get("value");
        for (Iterator iterator = keycodes.iterator(); iterator.hasNext();) {
            int keycode = (int) iterator.next();
            mDevice.pressKeyCode(keycode);
        }
        return NanoHTTPD.newFixedLengthResponse(getStatus(), getMimeType(), new Response(result, sessionId).toString());
    } catch (Exception e) {
        return NanoHTTPD.newFixedLengthResponse(getStatus(), getMimeType(), new Response(Status.UnknownError, sessionId).toString());
    }
}
 
开发者ID:macacajs,项目名称:UIAutomatorWD,代码行数:21,代码来源:KeysController.java

示例5: fromArrayToBundle

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
public static void fromArrayToBundle(Bundle bundle, String key, Object array) {
    if (bundle != null && !TextUtils.isEmpty(key) && array != null) {
        if (array instanceof String[]) {
            bundle.putStringArray(key, (String[]) ((String[]) array));
        } else if (array instanceof byte[]) {
            bundle.putByteArray(key, (byte[]) ((byte[]) array));
        } else if (array instanceof short[]) {
            bundle.putShortArray(key, (short[]) ((short[]) array));
        } else if (array instanceof int[]) {
            bundle.putIntArray(key, (int[]) ((int[]) array));
        } else if (array instanceof long[]) {
            bundle.putLongArray(key, (long[]) ((long[]) array));
        } else if (array instanceof float[]) {
            bundle.putFloatArray(key, (float[]) ((float[]) array));
        } else if (array instanceof double[]) {
            bundle.putDoubleArray(key, (double[]) ((double[]) array));
        } else if (array instanceof boolean[]) {
            bundle.putBooleanArray(key, (boolean[]) ((boolean[]) array));
        } else if (array instanceof char[]) {
            bundle.putCharArray(key, (char[]) ((char[]) array));
        } else {
            if (!(array instanceof JSONArray)) {
                throw new IllegalArgumentException("Unknown array type " + array.getClass());
            }

            ArrayList arraylist = new ArrayList();
            JSONArray jsonArray = (JSONArray) array;
            Iterator it = jsonArray.iterator();

            while (it.hasNext()) {
                JSONObject object = (JSONObject) it.next();
                arraylist.add(fromJsonToBundle(object));
            }

            bundle.putParcelableArrayList(key, arraylist);
        }

    }
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:40,代码来源:ArgumentsUtil.java

示例6: testJSONToResult

import com.alibaba.fastjson.JSONArray; //导入方法依赖的package包/类
@Test
public void testJSONToResult() {
    String json = "[{\"host\":\"127.0.0.1\"},{\"host\":\"127.0.0.1\"},{\"host\":\"127.0.0.1.012\"}]";

    try {
        JSONArray array = JSON.parseArray(json);
        // System.out.println(array);
        Assert.assertEquals(array.toString(),
                "[{\"host\":\"127.0.0.1\"},{\"host\":\"127.0.0.1\"},{\"host\":\"127.0.0.1.012\"}]");
        List<TagResult> arrayList = new ArrayList<TagResult>(array.size());

        Iterator<Object> iterator = array.iterator();
        while (iterator.hasNext()) {
            JSONObject object = (JSONObject) iterator.next();
            Set<Entry<String, Object>> entrySet = object.entrySet();
            for (Entry<String, Object> entry : entrySet) {
                String key = entry.getKey();
                Assert.assertNotEquals(key, null);
                Object valueObject = entry.getValue();
                Assert.assertNotEquals(key, null);
                String value = valueObject.toString();
                TagResult tagResult = new TagResult(key, value);
                arrayList.add(tagResult);
                break;
            }
        }
        Assert.assertEquals(arrayList.size(), 3);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

}
 
开发者ID:aliyun,项目名称:HiTSDB-Client,代码行数:33,代码来源:TestTagResult.java


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