Example usage for com.facebook.react.bridge ReadableMap keySetIterator

List of usage examples for com.facebook.react.bridge ReadableMap keySetIterator

Introduction

In this page you can find the example usage for com.facebook.react.bridge ReadableMap keySetIterator.

Prototype

@NonNull
    ReadableMapKeySetIterator keySetIterator();

Source Link

Usage

From source file:it.near.sdk.reactnative.rnnearitsdk.RNNearItUtils.java

License:Mozilla Public License

public static JSONObject toJSONObject(ReadableMap readableMap) throws JSONException {
    JSONObject jsonObject = new JSONObject();

    ReadableMapKeySetIterator iterator = readableMap.keySetIterator();

    while (iterator.hasNextKey()) {
        String key = iterator.nextKey();
        ReadableType type = readableMap.getType(key);

        switch (type) {
        case Null:
            jsonObject.put(key, null);/*  w w w.j  ava  2  s .  c  o m*/
            break;
        case Boolean:
            jsonObject.put(key, readableMap.getBoolean(key));
            break;
        case Number:
            jsonObject.put(key, readableMap.getDouble(key));
            break;
        case String:
            jsonObject.put(key, readableMap.getString(key));
            break;
        case Map:
            jsonObject.put(key, toJSONObject(readableMap.getMap(key)));
            break;
        case Array:
            jsonObject.put(key, toJSONArray(readableMap.getArray(key)));
            break;
        }
    }

    return jsonObject;
}

From source file:it.near.sdk.reactnative.rnnearitsdk.RNNearItUtils.java

License:Mozilla Public License

public static Map<String, Object> toMap(ReadableMap readableMap) {
    Map<String, Object> map = new HashMap<>();
    ReadableMapKeySetIterator iterator = readableMap.keySetIterator();

    while (iterator.hasNextKey()) {
        String key = iterator.nextKey();
        ReadableType type = readableMap.getType(key);

        switch (type) {
        case Null:
            map.put(key, null);/*from   w  w w  .j  a  v  a2 s  .  c o m*/
            break;
        case Boolean:
            map.put(key, readableMap.getBoolean(key));
            break;
        case Number:
            map.put(key, readableMap.getDouble(key));
            break;
        case String:
            map.put(key, readableMap.getString(key));
            break;
        case Map:
            map.put(key, toMap(readableMap.getMap(key)));
            break;
        case Array:
            map.put(key, toArray(readableMap.getArray(key)));
            break;
        }
    }

    return map;
}

From source file:org.jitsi.meet.sdk.ListenerUtils.java

License:Apache License

/**
 * Initializes a new {@code HashMap} instance with the key-value
 * associations of a specific {@code ReadableMap}.
 *
 * @param readableMap the {@code ReadableMap} specifying the key-value
 * associations with which the new {@code HashMap} instance is to be
 * initialized.//from ww  w .j ava  2  s.  c om
 * @return a new {@code HashMap} instance initialized with the key-value
 * associations of the specified {@code readableMap}.
 */
private static HashMap<String, Object> toHashMap(ReadableMap readableMap) {
    HashMap<String, Object> hashMap = new HashMap<>();

    for (ReadableMapKeySetIterator i = readableMap.keySetIterator(); i.hasNextKey();) {
        String key = i.nextKey();

        hashMap.put(key, readableMap.getString(key));
    }

    return hashMap;
}

From source file:rn.crashlytics.answers.AnswersModule.java

License:Open Source License

@ReactMethod
public void logCustom(String eventName, ReadableMap customAttributes) {
    final CustomEvent event = new CustomEvent(eventName);

    if (customAttributes != null) {
        final ReadableMapKeySetIterator readableMapKeySetIterator = customAttributes.keySetIterator();

        while (readableMapKeySetIterator.hasNextKey()) {
            final String key = readableMapKeySetIterator.nextKey();
            addCustomAttribute(event, customAttributes, key);
        }/* w  w  w. ja va 2s . co  m*/
    }

    answers.logCustom(event);
}