{ "id": "172897", "key": "TIMOB-26756", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "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": "2019-01-21T06:15:50.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [ "android", "ios", "log", "parity" ], "versions": [], "issuelinks": [ { "id": "58071", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "85301", "key": "TIMOB-7731", "fields": { "summary": "Android: Objects passed to \"Ti.API.debug\" should be printed as JSON", "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" } }, "priority": { "name": "Low", "id": "4" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } } ], "assignee": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2020-01-08T18:31:04.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": "10202", "name": "Android", "description": "Android Platform" } ], "description": "We noticed that logs between iOS and Android differ. On iOS, an object is printed with it's keys, so it can be inspected. On Android, it only prints {{\\[object Object\\]}}, requiring to manually stringify it. Unifying it would be a quick but useful improvement to the SDK.", "attachment": [], "flagged": false, "summary": "Android: Object details should be printed instead of \"[object Object]\" (parity)", "creator": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "environment": null, "comment": { "comments": [ { "id": "445541", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "When I tested the below, the behavior between Android and iOS were the same.\r\n{code:javascript}\r\nvar window = Ti.UI.createWindow();\r\nwindow.addEventListener(\"open\", function(e) {\r\n\tTi.API.info(\"@@@ e.toString(): \" + e);\r\n\tTi.API.info(\"@@@ JSON.stringify(e): \" + JSON.stringify(e));\r\n});\r\nwindow.open();\r\n{code}\r\n\r\nWhen concatenating a Titanium object to a JavaScript string, both Android and iOS return {{\"[object Object\"}}.\r\n\r\nAnd {{JSON.stringify()}} correctly returns a JSON of all of the object's enumerable properties on both Android and iOS.\r\n\r\nCan you give me a code snippet please? I'm curious where you're seeing the difference. Thanks.\r\n", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-01-23T03:45:42.000+0000", "updated": "2019-01-23T03:45:42.000+0000" }, { "id": "445566", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "In our case, we very often log plain objects, e.g. {{console.log({ hello: 'world' });}} On iOS, it will be displayed \"kind\" of stringified - at least a bit formatted (which is done by the internal iOS logging of the underlaying {{NSDictionary}} object). On Android, it does not attempt to show any key/values but onky the above {{[object Object]}}. I hope that can reproduce it. But still no blocker, all okay!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-01-23T17:08:08.000+0000", "updated": "2019-01-23T17:08:08.000+0000" }, { "id": "445608", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Okay. I've confirmed that both Android and Windows return {{\\[object Object\\]}} when doing the below.\r\n{code:javascript}\r\nvar table = {\r\n\tmyBoolean: true,\r\n\tmyNumber: 123.456,\r\n\tmyString: \"Hello World\",\r\n};\r\nTi.API.info(\"@@@ table: \" + table);\r\n{code}\r\n\r\nInteresting. iOS and Windows both use JavaScriptCore. So, I'm guessing we have written something custom on the iOS side to JSON stringify a dictionary. It's probably not a built-in JavaScriptCore things since the Windows results are the same as Android.\r\n\r\n", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-01-24T00:43:05.000+0000", "updated": "2019-01-24T00:43:24.000+0000" }, { "id": "445609", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "So, the below works on Titanium for Windows. It also works in node.js too. Not sure if it's a wise idea or not, but here it is.\r\n{code:java}\r\nObject.prototype.toString = function() {\r\n\treturn JSON.stringify(this);\r\n};\r\n{code}\r\n\r\nUnfortunately, the above won't work on Android. Not sure why. But in the end, the solution is to {{JSON.stringify()}} the dictionary.\r\n", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-01-24T01:12:06.000+0000", "updated": "2019-01-24T01:12:06.000+0000" }, { "id": "445646", "author": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~jquick] That works on Android, I put it in the {{ti.main.js}}", "updateAuthor": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-01-24T22:47:11.000+0000", "updated": "2019-01-24T22:47:11.000+0000" }, { "id": "445650", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Oh interesting. It turns out the JS minify prevents the below from working, which is used by default when doing a \"development\" or \"production\" build. When you build for Android emulator (ie: \"test\" build), a JS minify does not happen and the below solutions works fine.\r\n{code:javascript}\r\nObject.prototype.toString = function() {\r\n\treturn JSON.stringify(this);\r\n};\r\nvar table = {\r\n\tmyBoolean: true,\r\n\tmyNumber: 123.456,\r\n\tmyString: \"Hello World\",\r\n};\r\nTi.API.info(\"@@@ table: \" + table);\r\n{code}\r\n\r\nSo, I got the above to work for a device/development build via the following command line...\r\n{code}\r\nappc run -p android -T device -C \"\" --skip-js-minify\r\n{code}\r\n", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-01-24T23:49:33.000+0000", "updated": "2019-01-24T23:49:33.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }