Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19181] Windows: Implement toJSON for Titanium proxy classes

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2015-07-22T11:52:59.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsWindows
Labelsn/a
ReporterChristopher Williams
AssigneeKota Iguchi
Created2015-07-06T23:31:00.000+0000
Updated2017-03-17T18:06:48.000+0000

Description

Calling JSON.stringify(proxy) on a Titanium proxy results in an error. We can control the JSON representation that a custom class returns by having a special toJSON() function that returns a JSObject, which is then converted internally by JSC into JSON. https://github.com/appcelerator/webkit/blob/master/Source/JavaScriptCore/runtime/JSONObject.cpp#L328 Even if we can't get a great initial representation, we may be able to simply return undefined and avoid this runtime error?

Comments

  1. Christopher Williams 2015-07-07

    https://github.com/appcelerator/titanium_mobile/blob/0ff8c6818ca7a1b1cd0da18c11c60bab00ccb423/android/modules/ui/src/js/ui.js#L91 https://github.com/appcelerator/titanium_mobile/blob/17dc8754653daaff170ea0c18f74218168a5633e/android/runtime/common/src/js/titanium.js#L304 https://github.com/appcelerator/titanium_mobile/blob/0ff8c6818ca7a1b1cd0da18c11c60bab00ccb423/iphone/Classes/TiProxy.m#L1293
  2. Kota Iguchi 2015-07-22

  3. Lee Morris 2017-03-17

    Closing ticket as invalid.

JSON Source