cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] maverickmishra closed pull request #143: CB-11118: Add support for Array and Object params in iOS
Date Thu, 01 Jan 1970 00:00:00 GMT
maverickmishra closed pull request #143: CB-11118: Add support for Array and Object params
in iOS
URL: https://github.com/apache/cordova-plugin-file-transfer/pull/143
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/ios/CDVFileTransfer.m b/src/ios/CDVFileTransfer.m
index 4775a6d..a245a69 100644
--- a/src/ios/CDVFileTransfer.m
+++ b/src/ios/CDVFileTransfer.m
@@ -25,6 +25,7 @@ Licensed to the Apache Software Foundation (ASF) under one
 #import <AssetsLibrary/ALAssetRepresentation.h>
 #import <AssetsLibrary/ALAssetsLibrary.h>
 #import <CFNetwork/CFNetwork.h>
+#import <Foundation/NSJSONSerialization.h>
 
 #ifndef DLog
 #ifdef DEBUG
@@ -203,6 +204,11 @@ - (NSURLRequest*)requestForUploadCommand:(CDVInvokedUrlCommand*)command
fileData
         if ([val respondsToSelector:@selector(stringValue)]) {
             val = [val stringValue];
         }
+        // if it is a valid json object get the NSString representation
+        if ([NSJSONSerialization isValidJSONObject:val]){
+            NSData *jsonData = [NSJSONSerialization dataWithJSONObject:val options:NSJSONWritingPrettyPrinted
error:nil];
+            val = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
+        }
         // finally, check whether it is a NSString (for dataUsingEncoding selector below)
         if (![val isKindOfClass:[NSString class]]) {
             continue;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message