Repository: firebase/firebase-ios-sdk (language: cpp)

Issue:
FR: Support array / dictionary values in remote config defaults
<!-- DO NOT DELETE
validate_template=true
template_path=.github/ISSUE_TEMPLATE/feature_request.md
-->

### Feature proposal

* Firebase Component: Remote Config

JSON arrays / objects are supported as remote config parameter values, but are not currently supported as values in the property list provided to `setDefaults(fromPlist:)`



Discussion / hints:

Fix patch:
diff --git a/FirebaseRemoteConfig/Sources/RCNConfigContent.m b/FirebaseRemoteConfig/Sources/RCNConfigContent.m
index f10a78096c2..494a960a0a4 100644
--- a/FirebaseRemoteConfig/Sources/RCNConfigContent.m
+++ b/FirebaseRemoteConfig/Sources/RCNConfigContent.m
@@ -197,6 +197,20 @@ - (void)copyFromDictionary:(NSDictionary *)fromDict
         [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
         NSString *strValue = [dateFormatter stringFromDate:(NSDate *)value];
         valueData = [(NSString *)strValue dataUsingEncoding:NSUTF8StringEncoding];
+      } else if ([value isKindOfClass:[NSArray class]]) {
+        NSError *error;
+        valueData = [NSJSONSerialization dataWithJSONObject:value options:0 error:&error];
+        if (error) {
+          FIRLogError(kFIRLoggerRemoteConfig, @"I-RCN000076", @"Invalid array value for key '%@'",
+                      key);
+        }
+      } else if ([value isKindOfClass:[NSDictionary class]]) {
+        NSError *error;
+        valueData = [NSJSONSerialization dataWithJSONObject:value options:0 error:&error];
+        if (error) {
+          FIRLogError(kFIRLoggerRemoteConfig, @"I-RCN000077",
+                      @"Invalid dictionary value for key '%@'", key);
+        }
       } else {
         continue;
       }
diff --git a/FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m b/FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m
index 72e07a05067..9e9db1f5316 100644
--- a/FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m
+++ b/FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m
@@ -1285,6 +1285,10 @@ - (void)testSetDefaultsFromPlist {
     XCTAssertEqualObjects(_configInstances[i][@"FileInfo"].stringValue,
                           @"To setup default config.");
     XCTAssertEqualObjects(_configInstances[i][@"format"].stringValue, @"key to value.");
+    XCTAssertEqualObjects(_configInstances[i][@"arrayValue"].JSONValue,
+                          ((id) @[ @"foo", @"bar", @"baz" ]));
+    XCTAssertEqualObjects(_configInstances[i][@"dictValue"].JSONValue,
+                          ((id) @{@"foo" : @"foo", @"bar" : @"bar", @"baz" : @"baz"}));
 
     // If given a wrong file name, the default will not be set and kept as previous results.
     [_configInstances[i] setDefaultsFromPlistFileName:@""];


Test patch:
diff --git a/FirebaseRemoteConfig/Tests/Unit/Defaults-testInfo.plist b/FirebaseRemoteConfig/Tests/Unit/Defaults-testInfo.plist
index a8975fa800a..f734afb55ca 100644
--- a/FirebaseRemoteConfig/Tests/Unit/Defaults-testInfo.plist
+++ b/FirebaseRemoteConfig/Tests/Unit/Defaults-testInfo.plist
@@ -16,5 +16,20 @@
 	<string>To setup default config.</string>
 	<key>format</key>
 	<string>key to value.</string>
+	<key>arrayValue</key>
+	<array>
+		<string>foo</string>
+		<string>bar</string>
+		<string>baz</string>
+	</array>
+	<key>dictValue</key>
+	<dict>
+		<key>foo</key>
+		<string>foo</string>
+		<key>bar</key>
+		<string>bar</string>
+		<key>baz</key>
+		<string>baz</string>
+	</dict>
 </dict>
 </plist>