Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2614] JSON.stringify failing for droid

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:59:36.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.6.0 M05
ComponentsAndroid
Labelsandroid, defect, release-1.6.0, reported-1.5.1
ReporterAndreas sandberg
AssigneeDon Thorp
Created2011-04-15T03:24:48.000+0000
Updated2011-04-17T01:59:36.000+0000

Description

With droid on 1.5.1 the stringify function seems to be returning inconsistent results. Everything works as expected with iphone.

var r2 = JSON.stringify( {'0':'asf'} );
Ti.API.error("Rest data: " + r2);
//Rest data: {"0":null}

var r3 = JSON.stringify(['abc','def'] );
Ti.API.error("Rest data: " + r3);
//Rest data: ["abc", "def"]

var o = {'def':'abc'};
var r4 = JSON.stringify( o );
Ti.API.error("Rest data: " + r4);
//Rest data: {def

var user ='me';
var pass = 'mypass';
var enc = 'encoded';

var credentials = {'user_name':user,'password':pass,'encryption' : enc};
var restData = JSON.stringify({'0':credentials,'1':'mobile','2':{'name_value_list':{}}});
Ti.API.error("Rest data: " + restData);
//Rest data: {"2":null,"1":null,"0":null}

var credentials = {'user_name':user,'password':pass,'encryption' : enc};
var tmp = {'0':credentials,'1':'mobile','2':{'name_value_list':{}}};
var restData = JSON.stringify(tmp);
Ti.API.error("Rest data: " + restData);
//Rest data: {"2":null,"1":null,"0":null}

Comments

  1. Don Thorp 2011-04-15

    @Matt Will you create a unit test for this. It should apply to both platforms.

  2. Marshall Culpepper 2011-04-15

    (from [4665727d92384c4144283c114a46268250f9ac87]) check both string and integer types from Rhino, fixing Object->KrollDict conversion and JSON conversion [#2614 state:fixed-in-qa]
    https://github.com/appcelerator/titanium_mobile/commit/4665727d92384c4144283c114a46268250f9ac87"> https://github.com/appcelerator/titanium_mobile/commit/4665727d9238...

  3. Thomas Huelbert 2011-04-15

    [INFO] Titanium SDK version: 1.6.0 (01/13/11 08:11 7ca73a3) G1 (1.6) em (2.1) and droid1 (2.2.1), added to qa tests

JSON Source