From 8232c47dcfd4e5bc2244927512588da213f77418 Mon Sep 17 00:00:00 2001 From: Felipe Perez Date: Wed, 15 Feb 2023 14:04:52 -0800 Subject: [PATCH] Make JSONArguments accept Long values Summary: This util class was introduced in D42978852 (https://github.com/facebook/react-native/commit/611f9c615ebad7d53c1eb1274fe82e36d915165e), but the Long type was not ported over. Not sure if this was intentional or not, but this is used from return values from DeviceConfig, where number values are encoded as Long types. Changelog: [Internal] - internal Differential Revision: D43323851 fbshipit-source-id: 6a8a27b75b1738f2f87dd56ee814316af323c258 --- .../main/java/com/facebook/react/bridge/JSONArguments.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSONArguments.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSONArguments.java index 7fb9cc131a5..6e336ba1a88 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSONArguments.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSONArguments.java @@ -38,6 +38,8 @@ public class JSONArguments { result.putInt(key, (Integer) val); } else if (val instanceof Double) { result.putDouble(key, (Double) val); + } else if (val instanceof Long) { + result.putInt(key, ((Long) val).intValue()); } else if (obj.isNull(key)) { result.putNull(key); } else { @@ -83,6 +85,8 @@ public class JSONArguments { result.pushInt((Integer) val); } else if (val instanceof Double) { result.pushDouble((Double) val); + } else if (val instanceof Long) { + result.pushInt(((Long) val).intValue()); } else if (arr.isNull(i)) { result.pushNull(); } else {