Ticket #360 (closed defect: invalid)

Opened 3 years ago

Last modified 3 months ago

toJSONString problems

Reported by: Andrea Giammarchi Assigned to: anonymous
Type: defect Priority: major
Component: RefImpl Version: 4
Keywords: Cc:

Description

toJSONString method doesn't work with arrays. It returns [undefined]

with (new byte(0xFF)).toJSONStriong() returns an empty object (double variables as well), while with (new String("test")).toJSONString() it works as expected.

The same if you try

var b:byte = 0x01;
b; // 1
b.toJSONString(); // {}

Boolean, Number, int, uint, Object, Date and some other.

functions has different behaviours, probably this is expected. A function.toJSONString() is an empty object. A function with public "static" variables, with toJSONString() return an object with its public "static" values.

ECMAScript Edition 4 RI v0.0M2 (Tue Feb 12 14:20:55 2008)
>> var f:Function = function(){};
>> f.a = "b";
b
>> f.toJSONString();
{"a":"b"}
>> f.b = function(){};
[function Function]
>> f.b();
>> f.toJSONString();
[locn] c:\Documents and Settings\dherman\My Documents\ES4Model\builtins\Error.es
:85:55-85.55
[stack] [toJSONString() | formatObject([function Function], false) | fmtObject([
function Function]) | fmtFields([function Function], 2) | activate([function Fun
ction]) | deactivate([function Function]) | slice(0, 1) | init step()]
**ERROR** EvalError: uncaught exception: TypeError: incompatible types w/o conve
rsion: val=undefined type=undefined wanted=(byte|int|uint|double|decimal|Number)
 (near c:\Documents and Settings\dherman\My Documents\ES4Model\builtins\Error.es
:85:55-85.55)

decimal.toJSONString() kill my shell (Windows XP full updated)

ECMAScript Edition 4 RI v0.0M2 (Tue Feb 12 14:20:55 2008)
>> var d:decimal = 1.2;
>> d
1.2
>> d.toJSONString(); // bye bye

Attachments

Change History

Changed 3 years ago by lth

  • owner deleted
  • component changed from Proposals to RefImpl

Changed 2 years ago by David-Sarah Hopwood

  • status changed from new to closed
  • resolution set to invalid

Invalid because ES3.1 doesn't specify a toJSONString method; it specifies the JSON global. Lack of support for that in the RefImpl? should be a new issue.

Changed 2 years ago by David-Sarah Hopwood

Lack of support for JSON in the RefImpl? is ticket #201.

Changed 3 months ago by anonymous

  • milestone deleted

Milestone M2 deleted

Note: See TracTickets for help on using tickets.