{ "id": "79549", "key": "TIMOB-5499", "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": [ { "id": "12084", "description": "", "name": "Sprint 2011-44", "archived": true, "released": true, "releaseDate": "2011-11-07" } ], "resolution": { "id": "5", "description": "All attempts at reproducing this issue failed, or not enough information was available to reproduce the issue. Reading the code produces no clues as to why this behavior would occur. If more information appears later, please reopen the issue.", "name": "Cannot Reproduce" }, "resolutiondate": "2011-10-31T15:56:53.000+0000", "created": "2011-08-23T11:29:45.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "json", "parse" ], "versions": [ { "id": "11570", "description": "", "name": "Release 1.7.2", "archived": true, "released": true, "releaseDate": "2011-07-21" } ], "issuelinks": [], "assignee": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-31T17:24:13.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "In Android only this returns an error to the like of: [Ljava.lang.Object;@43fd4198\r\n\r\n{code:javascript|title=app.js}\r\ntxt = '{\"a\": [5,6]}';\r\nTi.API.info(\"JSON.parse(txt).a[0]: \" + JSON.parse(txt).a[0]);\r\nTi.API.info(\"JSON.parse(txt): \" + JSON.parse(txt));\r\n{code}\r\n\r\niOS processes with no error.", "attachment": [], "flagged": false, "summary": "JSON.parse returns [Ljava.lang.Object;@43fd4198 in Android", "creator": { "name": "mstacy", "key": "mstacy", "displayName": "Matt Stacy", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "mstacy", "key": "mstacy", "displayName": "Matt Stacy", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Mobile\r\nTitanium Mobile SDK 1.7.2\r\nAndroid 2.2\r\nAndroid Emulator\r\nOSX 10.6.8\r\nTitanium Studio 1.0.4.201108101535\r\n", "comment": { "comments": [ { "id": "163840", "author": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Yes, that's how object are printed and sometimes arrays also. It's totally useless.\r\n\r\n\r\nAlthough, you can use them without any problem (try: \"Ti.API.info(txt.a[0])\").", "updateAuthor": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2011-08-24T01:32:02.000+0000", "updated": "2011-08-24T01:32:02.000+0000" }, { "id": "166017", "author": { "name": "rmunson", "key": "rmunson", "displayName": "Russell Munson", "active": true, "timeZone": "America/New_York" }, "body": "This also affects property enumeration. Methods on the object are objects rather than functions.\r\nEx:\r\n\r\n{code:language=Javascript}\r\n(function(){\r\nvar obj=JSON.parse('{\"test\":\"yes\"}'),\r\n key;\r\n\r\nTi.UI.createWindow({\r\n backgroundColor : 'red'\r\n}).open();\r\n\r\nfor(key in obj){\r\n if(obj.hasOwnProperty(key)){\r\n Ti.API.log(\"hasOwnProp\",obj[key].hasOwnProperty('park'));\r\n }\r\n}\r\n})();\r\n{code}\r\n\r\n09-14 13:59:50.783: ERROR/KrollContext(5042): (kroll$1: app://app.js) [338,718] ECMA Error evaluating source: TypeError: Cannot call property hasOwnProperty in object { 'test' : 'yes' }. It is not a function, it is \"object\". (file:///android_asset/Resources/app.js#12)\r\n", "updateAuthor": { "name": "rmunson", "key": "rmunson", "displayName": "Russell Munson", "active": true, "timeZone": "America/New_York" }, "created": "2011-09-14T10:58:16.000+0000", "updated": "2011-09-14T11:02:08.000+0000" }, { "id": "166844", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Matt\r\n\r\n[Ljava.lang.Object;@44cea438 is not an error, it is an object reference. Try the following:\r\n\r\n{code:javascript|title=app.js}\r\ntxt = '{\"a\": [5,6]}';\r\nTi.API.info(\"JSON.parse(txt).a[0]: \" + JSON.parse(txt).a[0]);\r\nTi.API.info(\"typeof(JSON.parse(txt)): \" + typeof(JSON.parse(txt)));\r\n{code}\r\n\r\nPlease note in the [Jira Ticket Checklist|http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-Summary%3AJiraTicketChecklist] where it requires that you consult the community before raising a ticket.\r\n\r\nThanks", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-09-23T16:44:31.000+0000", "updated": "2011-09-23T16:44:31.000+0000" }, { "id": "167577", "author": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Paul,\r\n\r\n\r\nthat strange hash code may not be an error, but I think that's not the point. If you want to *debug* some variable, what is the point of outputting that strange hash code?\r\n\r\nHash code/object reference id is totally useless when you are trying to *debug* values in some object. That's why, IMHO, debug output should contain string produced by \"JSON.stringify\" function. That output is useful for *debugging*.\r\n\r\n\r\nAlso, see this:\r\n\r\n{code}\r\nvar txt = '{\"a\": [5,6]}';\r\nvar obj = JSON.parse(txt);\r\n\r\nvar jsObj = { a: [5,6] };\r\n\r\nTi.API.info(\"parse \" + obj.toString());\r\nTi.API.info(\"native \" + jsObj.toString());\r\n\r\n// parse { 'a' : [Ljava.lang.Object;@483515e8 }\r\n// native [object Object]\r\n{code}\r\n\r\nThe second output is the right one.\r\n\r\n\"obj\" contains object reference, but it is not printed as strange hash code, but it's property that contains an array is. It seems to me that is not consistent (and if I may presume, object returned by \"JSON.parse\" doesn't behave identical as native JS object because I found some more strange things regarding \"JSON.parse\" but I didn't try to isolate the issues because I have some more important things to do :( )", "updateAuthor": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2011-10-03T07:23:37.000+0000", "updated": "2011-10-03T07:23:37.000+0000" }, { "id": "168958", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Matt\r\n\r\nThanks for raising the ticket and making the case for this change in behavior. I have moved it to the main project, for the core team's consideration.\r\n\r\nRegards", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-10-12T01:31:00.000+0000", "updated": "2011-10-12T01:31:00.000+0000" }, { "id": "169155", "author": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "body": "We switched to the Rhino-based JSON parser recently in master, we should verify this issue is also fixed by the move", "updateAuthor": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-10-13T11:52:49.000+0000", "updated": "2011-10-13T11:52:49.000+0000" }, { "id": "169279", "author": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Yes, this seems to be fixed in master build. Tnx", "updateAuthor": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2011-10-14T00:36:05.000+0000", "updated": "2011-10-14T00:36:05.000+0000" }, { "id": "170973", "author": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Tested original test case, and I got:\r\n\r\nJSON.parse(txt).a[0]: 5\r\nJSON.parse(txt): [object Object]\r\n\r\nIt doesn't seem to return a hash string anymore.", "updateAuthor": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-10-31T15:56:53.000+0000", "updated": "2011-10-31T15:56:53.000+0000" }, { "id": "416504", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as it has been over 5 years since the last update. Please open a new ticket if you have a problem.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-31T17:24:13.000+0000", "updated": "2017-03-31T17:24:13.000+0000" } ], "maxResults": 10, "total": 10, "startAt": 0 } } }