mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Remove the com.facebook.react.bridge.JSONArguments class (#52901)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52901 I'm removing this class as we should not expose it publicly. It's not used at all inside react-native and can potentally be moved internally. The only usage I've found in OSS is patched with this PR: - https://github.com/fabOnReact/react-native-wear-connectivity/pull/46 Changelog: [Android] [Removed] - Remove the `com.facebook.react.bridge.JSONArguments` class Reviewed By: javache, mdvacca Differential Revision: D78265165 fbshipit-source-id: 704575e7b9cfd6d40980511d6064d39991b3eb48
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ec5a98b1f5
commit
04ae15d99b
@@ -816,14 +816,6 @@ public abstract interface class com/facebook/react/bridge/JSInstance {
|
||||
public abstract fun invokeCallback (ILcom/facebook/react/bridge/NativeArrayInterface;)V
|
||||
}
|
||||
|
||||
public final class com/facebook/react/bridge/JSONArguments {
|
||||
public static final field INSTANCE Lcom/facebook/react/bridge/JSONArguments;
|
||||
public static final fun fromJSONArray (Lorg/json/JSONArray;)Lcom/facebook/react/bridge/ReadableArray;
|
||||
public static final fun fromJSONArrayString (Ljava/lang/String;)Lcom/facebook/react/bridge/ReadableArray;
|
||||
public static final fun fromJSONObject (Lorg/json/JSONObject;)Lcom/facebook/react/bridge/ReadableMap;
|
||||
public static final fun fromJSONObjectString (Ljava/lang/String;)Lcom/facebook/react/bridge/ReadableMap;
|
||||
}
|
||||
|
||||
public final class com/facebook/react/bridge/JavaOnlyArray : com/facebook/react/bridge/ReadableArray, com/facebook/react/bridge/WritableArray {
|
||||
public static final field Companion Lcom/facebook/react/bridge/JavaOnlyArray$Companion;
|
||||
public fun <init> ()V
|
||||
|
||||
-105
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.bridge
|
||||
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
|
||||
public object JSONArguments {
|
||||
/**
|
||||
* Parse JSONObject to ReadableMap
|
||||
*
|
||||
* @param obj The JSONObject to be parsed
|
||||
* @return readableMap from the JSONObject
|
||||
*/
|
||||
@JvmStatic
|
||||
@Throws(JSONException::class)
|
||||
public fun fromJSONObject(obj: JSONObject): ReadableMap {
|
||||
val keys = obj.keys()
|
||||
|
||||
val result = buildReadableMap {
|
||||
while (keys.hasNext()) {
|
||||
val key = keys.next()
|
||||
when (val value = obj.get(key)) {
|
||||
is JSONObject -> put(key, fromJSONObject(value))
|
||||
is JSONArray -> put(key, fromJSONArray(value))
|
||||
is String -> put(key, value)
|
||||
is Boolean -> put(key, value)
|
||||
is Int -> put(key, value)
|
||||
is Double -> put(key, value)
|
||||
is Long -> put(key, value.toInt())
|
||||
else ->
|
||||
if (obj.isNull(key)) {
|
||||
putNull(key)
|
||||
} else {
|
||||
throw JSONException("Unexpected value when parsing JSON object. key: $key")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse String of JSON object to ReadableMap
|
||||
*
|
||||
* @param objStr The String JSON object to be parsed
|
||||
* @return readableMap from the JSONArray
|
||||
*/
|
||||
@JvmStatic
|
||||
@Throws(JSONException::class)
|
||||
public fun fromJSONObjectString(objStr: String): ReadableMap {
|
||||
return fromJSONObject(JSONObject(objStr))
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse JSONArray to ReadableArray
|
||||
*
|
||||
* @param arr The JSONArray to be parsed
|
||||
* @return readableArray from the JSONArray
|
||||
*/
|
||||
@JvmStatic
|
||||
@Throws(JSONException::class)
|
||||
public fun fromJSONArray(arr: JSONArray): ReadableArray {
|
||||
val result = buildReadableArray {
|
||||
repeat(arr.length()) {
|
||||
when (val value = arr.get(it)) {
|
||||
is JSONObject -> add(fromJSONObject(value))
|
||||
is JSONArray -> add(fromJSONArray(value))
|
||||
is String -> add(value)
|
||||
is Boolean -> add(value)
|
||||
is Int -> add(value)
|
||||
is Double -> add(value)
|
||||
is Long -> add(value.toInt())
|
||||
else ->
|
||||
if (arr.isNull(it)) {
|
||||
addNull()
|
||||
} else {
|
||||
throw JSONException("Unexpected value when parsing JSON array. index: $it")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse String of JSON array to ReadableArray
|
||||
*
|
||||
* @param arrStr The String JSON array to be parsed
|
||||
* @return readableArray from the JSONArray
|
||||
*/
|
||||
@JvmStatic
|
||||
@Throws(JSONException::class)
|
||||
public fun fromJSONArrayString(arrStr: String): ReadableArray {
|
||||
return fromJSONArray(JSONArray(arrStr))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user