Skip to content

Instantly share code, notes, and snippets.

View contfedorov's full-sized avatar

Egor A. Fedorov contfedorov

  • Novosibirsk
  • 06:29 (UTC +07:00)
View GitHub Profile
@contfedorov
contfedorov / ReactNativeJson.java
Last active November 15, 2022 04:19 — forked from viperwarp/ReactNativeJson.java
React-Native Module, ReadableMap/Array to Java JSON objects
public static WritableMap convertJsonToMap(@NonNull JSONObject jsonObject) throws JSONException {
WritableMap map = Arguments.createMap();
Iterator<String> iterator = jsonObject.keys();
while (iterator.hasNext()) {
String key = iterator.next();
Object value = jsonObject.get(key);
if (value instanceof JSONObject) {
map.putMap(key, convertJsonToMap((JSONObject) value));
} else if (value instanceof JSONArray) {