本文整理匯總了Java中com.facebook.react.bridge.WritableMap.putNull方法的典型用法代碼示例。如果您正苦於以下問題:Java WritableMap.putNull方法的具體用法?Java WritableMap.putNull怎麽用?Java WritableMap.putNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.facebook.react.bridge.WritableMap
的用法示例。
在下文中一共展示了WritableMap.putNull方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: jsonToReact
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
public static WritableMap jsonToReact(JSONObject jsonObject) throws JSONException {
WritableMap writableMap = Arguments.createMap();
Iterator iterator = jsonObject.keys();
while(iterator.hasNext()) {
String key = (String) iterator.next();
Object value = jsonObject.get(key);
if (value instanceof Float || value instanceof Double) {
writableMap.putDouble(key, jsonObject.getDouble(key));
} else if (value instanceof Number) {
writableMap.putInt(key, jsonObject.getInt(key));
} else if (value instanceof String) {
writableMap.putString(key, jsonObject.getString(key));
} else if (value instanceof JSONObject) {
writableMap.putMap(key,jsonToReact(jsonObject.getJSONObject(key)));
} else if (value instanceof JSONArray){
writableMap.putArray(key, jsonToReact(jsonObject.getJSONArray(key)));
} else if (value == JSONObject.NULL){
writableMap.putNull(key);
}
}
return writableMap;
}
示例2: Member
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
public static WritableMap Member(Member member) {
WritableMap map = Arguments.createMap();
map.putMap("userInfo", UserInfo(member.getUserInfo()));
if (member.getLastConsumedMessageIndex() == null) {
map.putNull("lastConsumedMessageIndex");
}
else {
map.putInt("lastConsumedMessageIndex", member.getLastConsumedMessageIndex().intValue());
}
if (member.getLastConsumptionTimestamp() == null) {
map.putNull("lastConsumptionTimestamp");
}
else {
map.putString("lastConsumptionTimestamp", member.getLastConsumptionTimestamp());
}
return map;
}
示例3: toWritableMap
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
public static WritableMap toWritableMap(Map<String, Object> map) {
WritableMap writableMap = Arguments.createMap();
Iterator iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry pair = (Map.Entry)iterator.next();
Object value = pair.getValue();
if (value == null) {
writableMap.putNull((String) pair.getKey());
} else if (value instanceof Boolean) {
writableMap.putBoolean((String) pair.getKey(), (Boolean) value);
} else if (value instanceof Double) {
writableMap.putDouble((String) pair.getKey(), (Double) value);
} else if (value instanceof Integer) {
writableMap.putInt((String) pair.getKey(), (Integer) value);
} else if (value instanceof String) {
writableMap.putString((String) pair.getKey(), (String) value);
} else if (value instanceof Map) {
writableMap.putMap((String) pair.getKey(), MapUtil.toWritableMap((Map<String, Object>) value));
} else if (value.getClass() != null && value.getClass().isArray()) {
writableMap.putArray((String) pair.getKey(), ArrayUtil.toWritableArray((Object[]) value));
}
iterator.remove();
}
return writableMap;
}
示例4: fromBundle
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
public static WritableMap fromBundle(Bundle bundle) {
WritableMap map = Arguments.createMap();
for (String key: bundle.keySet()) {
Object value = bundle.get(key);
if (value == null) {
map.putNull(key);
} else if (value.getClass().isArray()) {
map.putArray(key, Arguments.fromArray(value));
} else if (value instanceof String) {
map.putString(key, (String) value);
} else if (value instanceof Number) {
if (value instanceof Integer) {
map.putInt(key, (Integer) value);
} else {
map.putDouble(key, ((Number) value).doubleValue());
}
} else if (value instanceof Boolean) {
map.putBoolean(key, (Boolean) value);
} else if (value instanceof Bundle) {
map.putMap(key, fromBundle((Bundle) value));
} else if (value instanceof List) {
map.putArray(key, fromArray(((List) value).toArray()));
} else {
throw new IllegalArgumentException("Could not convert " + value.getClass());
}
}
return map;
}
示例5: jsonToWritableMap
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
public static WritableMap jsonToWritableMap(JSONObject jsonObject) {
WritableMap writableMap = new WritableNativeMap();
if (jsonObject == null) {
return null;
}
Iterator<String> iterator = jsonObject.keys();
if (!iterator.hasNext()) {
return null;
}
try {
while (iterator.hasNext()) {
String key = iterator.next();
Object value = jsonObject.get(key);
if (value == null) {
writableMap.putNull(key);
} else if (value instanceof Boolean) {
writableMap.putBoolean(key, (Boolean) value);
} else if (value instanceof Integer) {
writableMap.putInt(key, (Integer) value);
} else if (value instanceof Double) {
writableMap.putDouble(key, (Double) value);
} else if (value instanceof String) {
writableMap.putString(key, (String) value);
} else if (value instanceof JSONObject) {
writableMap.putMap(key, jsonToWritableMap((JSONObject) value));
} else if (value instanceof JSONArray) {
writableMap.putArray(key, jsonArrayToWritableArray((JSONArray) value));
}
}
} catch (JSONException ex){
// Do nothing and fail silently
}
return writableMap;
}
示例6: toWritableMap
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
public static WritableMap toWritableMap(Map<String, Object> map) {
WritableMap writableMap = Arguments.createMap();
Iterator iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry pair = (Map.Entry) iterator.next();
Object value = pair.getValue();
if (value == null) {
writableMap.putNull((String) pair.getKey());
} else if (value instanceof Boolean) {
writableMap.putBoolean((String) pair.getKey(), (Boolean) value);
} else if (value instanceof Double) {
writableMap.putDouble((String) pair.getKey(), (Double) value);
} else if (value instanceof Integer) {
writableMap.putInt((String) pair.getKey(), (Integer) value);
} else if (value instanceof String) {
writableMap.putString((String) pair.getKey(), (String) value);
} else if (value instanceof Map) {
writableMap.putMap((String) pair.getKey(), MapUtil.toWritableMap((Map<String, Object>) value));
} else if (value.getClass() != null && value.getClass().isArray()) {
writableMap.putArray((String) pair.getKey(), ArrayUtil.toWritableArray((Object[]) value));
}
iterator.remove();
}
return writableMap;
}
示例7: toWritableMap
import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
public static WritableMap toWritableMap(Map<String, Object> map) {
WritableMap writableMap = Arguments.createMap();
Iterator iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry pair = (Map.Entry)iterator.next();
Object value = pair.getValue();
if (value == null) {
writableMap.putNull((String) pair.getKey());
} else if (value instanceof Boolean) {
writableMap.putBoolean((String) pair.getKey(), (Boolean) value);
} else if (value instanceof Double) {
writableMap.putDouble((String) pair.getKey(), (Double) value);
} else if (value instanceof Integer) {
writableMap.putInt((String) pair.getKey(), (Integer) value);
} else if (value instanceof String) {
writableMap.putString((String) pair.getKey(), (String) value);
} else if (value instanceof Map) {
writableMap.putMap((String) pair.getKey(), MapUtil.toWritableMap((Map<String, Object>) value));
} else if (value.getClass() != null && value.getClass().isArray()) {
writableMap.putArray((String) pair.getKey(), ArrayUtil.toWritableArray((Object[]) value));
}
iterator.remove();
}
return writableMap;
}