{ "id": "147215", "key": "TIMOB-18846", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2015-04-23T08:41:55.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [], "versions": [], "issuelinks": [], "assignee": null, "updated": "2018-02-28T19:55:54.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "A [Q&A user|https://community.appcelerator.com/topic/178/http-request-problem-with-array-data/3] discovered that when following the [docs|http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Network.HTTPClient-method-send] to send arrays, but if those arrays include objects, the result on iOS is different then it is on Android. The expected result is seen on Android, while the result on iOS is unusable because of added {{+}} characters, newlines and {{;}}.\r\n\r\nh1. To reproduce\r\n\r\nRun the following code on both iOS and Android with an updated requestb.in URL.\r\n\r\n{code}\r\nvar xhr = Titanium.Network.createHTTPClient();\r\n\r\nxhr.open('POST', 'http://requestb.in/101jps01');\r\n\r\nvar data = {\r\n\tstring: 'a',\r\n\tarrayOfStrings: ['a', 'b'],\r\n\tarrayOfObjects: [{\r\n\t\t'a': 'x'\r\n\t}, {\r\n\t\t'b': 'y',\r\n\t}]\r\n};\r\n\r\n//Dealing with arrays on data\r\nfor (var key in data) {\r\n\tif (Array.isArray(data[key])) {\r\n\t\tfor (var i = 0, l = data[key].length; i < l; i++) {\r\n\t\t\tdata[key + '[' + i + ']'] = data[key][i];\r\n\t\t}\r\n\t\tdelete data[key];\r\n\t}\r\n}\r\n\r\nconsole.log(data);\r\n\r\nxhr.send(data);\r\n{code}\r\n\r\nh1. Android\r\n\r\nThe {{console.log}} will show:\r\n\r\n{code}\r\n{\r\n\t\"string\": \"a\",\r\n\t\"arrayOfStrings[0]\": \"a\",\r\n\t\"arrayOfStrings[1]\": \"b\",\r\n\t\"arrayOfObjects[0]\": {\r\n\t\t\"a\": \"x\"\r\n\t},\r\n\t\"arrayOfObjects[1]\": {\r\n\t\t\"b\": \"y\"\r\n\t}\r\n}\r\n{code}\r\n\r\nThe body shown on requestb.in will be:\r\n\r\n{code}\r\narrayOfObjects%5B0%5D=%7Bc%3Dd%2C+a%3Db%7D&arrayOfStrings%5B0%5D=a&arrayOfStrings%5B1%5D=b&string=a\r\n{code}\r\n\r\nwhich decoded is the expected:\r\n\r\n{code}\r\narrayOfObjects[1]={b=y}&arrayOfObjects[0]={a=x}&arrayOfStrings[1]=b&arrayOfStrings[0]=a&string=a\r\n{code}\r\n\r\nh1. iOS\r\n\r\nThe {{console.log}} will show similar:\r\n\r\n{code}\r\n{\r\n \"arrayOfObjects[0]\" = {\r\n a = x;\r\n };\r\n \"arrayOfObjects[1]\" = {\r\n b = y;\r\n };\r\n \"arrayOfStrings[0]\" = a;\r\n \"arrayOfStrings[1]\" = b;\r\n string = a;\r\n}\r\n{code}\r\n\r\nBut the body shown on requestb.in will be:\r\n\r\n{code}\r\narrayOfStrings%5B1%5D=b&arrayOfObjects%5B0%5D=%7B%0A++++a+%3D+x%3B%0A%7D&arrayOfStrings%5B0%5D=a&arayOfObjects%5B1%5D=%7B%0A++++b+%3D+y%3B%0A%7D&string=a\r\n{code}\r\n\r\nwhich decoded is:\r\n\r\n{code}\r\narrayOfStrings[1]=b&arrayOfObjects[0]={\r\n++++a+=+x;\r\n}&arrayOfStrings[0]=a&arrayOfObjects[1]={\r\n++++b+=+y;\r\n}&string=a\r\n{code}\r\n\r\nh1. Solution\r\n\r\nThe Android output is better, although {{\\{b=y\\}}} is no valid JSON or form data either. It might better be {{\\{\"b\":\"y\"\\}}}?", "attachment": [], "flagged": false, "summary": "Parity: HTTPClient sends array of objects differently on iOS then it does on Android", "creator": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "subtasks": [], "reporter": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "environment": "SDK 3.5.1.GA", "comment": { "comments": [], "maxResults": 0, "total": 0, "startAt": 0 } } }