Coder Social home page Coder Social logo

mikechambers / as3corelib Goto Github PK

View Code? Open in Web Editor NEW
1.5K 1.5K 445.0 2.8 MB

An ActionScript 3 Library that contains a number of classes and utilities for working with ActionScript? 3. These include classes for MD5 and SHA 1 hashing, Image encoders, and JSON serialization as well as general String, Number and Date APIs.

ActionScript 100.00%

as3corelib's People

Contributors

cantrell avatar darronschall avatar mikechambers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

as3corelib's Issues

Standardize the API for image encoders

Originally filed by frozenandcold on 2007-06-04T17:59:31

The PNG encoder uses a static function "encode" while the JPG encoder
requires an instance of JPGEncoder.

It would be nice if one method was chosen and used for both for ease of
switching between them. This would then pave the way for future encoding
formats and would support reflection.

JSON cannot encode/decode date instances correctly

Originally filed by darron.schall on 2006-12-29T20:44:29

What steps will reproduce the problem?

  1. trace( JSON.encode( new Date() ) );

What is the expected output? What do you see instead?

The expected output, unfortunately, is not that well defined. There is no
standard JSON syntax for dealing with dates. A proposed standard is here:

http://www.nikhilk.net/DateSyntaxForJSON2.aspx

Essentially, serializing the date to "@Number@" where number is the number
of milliseconds that have passed since Jan 1, 1970.

Either that, or we can use one of the ISO Date Standard formats.

The output from the trace statement is simply {}. Clearly an empty object
is not good, not matter what the expected output should be.

Please use labels and text to provide additional information.

Whatever sort of serialization we implement should probably be specified
via a flag, passed to the static encode/decode methods. Something like:

JSON.encode( date, JSON.DATE_FORMAT_ISO_8601 );
or
JSON.encode( date, JSON.DATE_FORMAT_AT_MILLIS_AT );

Also, a the decode routine should be specified so that string matching the
encoding format will be converted into true Date instances.

WSSEUsernameToken: nonce incorrectly used to generate digest

Originally filed by epost001 on 2007-07-12T14:20:40

What steps will reproduce the problem?

  1. call WSSEUsernameToken.getUsernameToken("user", "password")

What is the expected output? What do you see instead?

In getUsernameToken, the nonce is base64-encoded. This encoded value is
then used in determining the password digest. This is not according to the
WS-Security UsernameToken specification: the password digest is based on
the unencoded nonce value.

What version of the product are you using? On what operating system?

ad3corelib .90

Please provide any additional information below.

parsing numbers with exponent fails

Originally filed by justintalbot on 2008-05-05T20:47:52

What steps will reproduce the problem?

  1. trace(JSON.decode("[3.6e-01]"));

What is the expected output? What do you see instead?
Expected: 0.36
Instead: "Unexpected e encountered"

What version of the product are you using? On what operating system?
AS 3 on Windows

Please provide any additional information below.
Browsing the source of JSONTokenizer.as reveals that exponents are not
handled at all.

JSON.decode("") throws a TypeError due to null pointer dereference; would be better to throw a JSONParseError

Originally filed by mmorearty on 2007-03-27T06:05:14

What steps will reproduce the problem?

  1. Execute this: JSON.decode("")

What is the expected output? What do you see instead?

The actual output is this exception:

TypeError: Error #1009: Cannot access a property or method of a null object
reference.
at com.adobe.serialization.json::JSONDecoder/::parseValue()

I'm pretty sure "" is not legal JSON, so it is correct to throw an
exception, but it would be better to throw a JSONParseError, so that users
who are anticipating possibly illegal JSON can write their code like this,
and have it catch the error:

try {
JSON.decode(blahblah);
} catch (e:JSONParseError) {
// deal with it
}

The way to fix this is, I think, to change JSONDecoder.parseValue() so that
at the top of the function, before "switch (token.type)", add this code:

if (token == null)
tokenizer.parseError("Unexpected end of input");

What version of the product are you using? On what operating system?
.90, on Windows

Please provide any additional information below.

Need SHA 384 Class

Originally filed by mikechambers on 2007-03-03T21:06:09

We need to impliment a SHA 384 Class.

Add UnitTest for PNGEncoder class

Originally filed by mikechambers on 2007-01-10T08:26:54

We need to add a unit test for the PNGEncoder class:

com.adobe.images.PNGEncoder

Runtime Error

Originally filed by jordanhewi on 2007-12-20T21:28:55

What steps will reproduce the problem?

  1. Run program that uses JSON in Flex Developer.

What is the expected output? What do you see instead?
I expected to see a web page that looked like the one in the designer.

Instead, I to the following output:

TypeError: Error #1009: Cannot access a property or method of a null object
reference.
at
com.adobe.serialization.json::JSONDecoder/com.adobe.serialization.json:JSONDecoder::parseValue()[C:\Development\ContractProjects\Adobe\as3corelib\src\com\adobe\serialization\json\JSONDecoder.as:197]
at
com.adobe.serialization.json::JSONDecoder$iinit()[C:\Development\ContractProjects\Adobe\as3corelib\src\com\adobe\serialization\json\JSONDecoder.as:64]
at
com.adobe.serialization.json::JSON$/decode()[C:\Development\ContractProjects\Adobe\as3corelib\src\com\adobe\serialization\json\JSON.as:81]
at main/main::eventJSON()[/Users/hewij/Documents/Flex Builder
2/PHPJSON/main.as:24]
at main/__eventRequest_result()[/Users/hewij/Documents/Flex Builder
2/PHPJSON/main.mxml:9]
at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at
mx.rpc.http.mxml::HTTPService/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[C:\dev\enterprise_bali\frameworks\mx\rpc\http\mxml\HTTPService.as:247]
at
mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C:\dev\enterprise_bali\frameworks\mx\rpc\AbstractInvoker.as:168]
at
mx.rpc::Responder/result()[C:\dev\enterprise_bali\frameworks\mx\rpc\Responder.as:48]
at
mx.rpc::AsyncRequest/acknowledge()[C:\dev\enterprise_bali\frameworks\mx\rpc\AsyncRequest.as:82]
at
DirectHTTPChannel.as$139::DirectHTTPMessageResponder/completeHandler()[C:\dev\enterprise_bali\frameworks\mx\messaging\channels\DirectHTTPChannel.as:359]
at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()

at flash.net::URLLoader/flash.net:URLLoader::onComplete()

What version of the product are you using? On what operating system?
The version of as3corelib is .90. The version of Flex is 2.0. My
operating system is a Mac.

Please provide any additional information below.

DateUtil.parseW3CDTF does not parse compliant dates

Originally filed by [email protected] on 2007-07-31T14:55:04

What steps will reproduce the problem?

  1. DateUtil.parseW3CDTF("2007-07-31");

What is the expected output? What do you see instead?
Expected output should be a properly parsed Date object. Instead an error
is generated with the text "Error: This date does not conform to W3CDTF.".

What version of the product are you using? On what operating system?
as3corelib 0.9, windows vista

Please provide any additional information below.
According to the spec listed in the documentation, there are 6 acceptable
levels for W3CDTF - one being the "YYYY-MM-DD" format. See
http://www.w3.org/TR/NOTE-datetime.

JSONParseError raised in JSONParseError.as has 'name' key commented out.

Originally filed by ingalls.jon on 2007-08-04T05:13:46

What steps will reproduce the problem?

  1. Pass a broken json string to a Flex app using corelib.as (import
    com.adobe.serialization.json.JSON;)
  2. Walk through the parsing in your favorite debugger.
  3. If the parser breaks it will enter into JSONParseError.as and attempt to
    define a JSONParseError. The name key is commented out.

See line 60 in JSONParseError.as

Here is the source code:

public function JSONParseError( message:String = "", location:int = 0,
text:String = "")
{
super( message );
//name = "JSONParseError";
_location = location;
_text = text;
}

What is the expected output? What do you see instead?
In flex I would like to catch the error using error.name, I can't do this
with the field commented out.

What version of the product are you using? On what operating system?
as3corelib

Please provide any additional information below.

Allow PNGEncoder to accept metadata

Originally filed by nickgsuperstar on 2007-08-20T02:58:15

Hi Folks,

Thanks for this project first of all. It's great.

I've had the need to add metadata to PNG images. So I added optional,
backward-compatible support for that in your PNGEncoder and the other
PNGEnc (http://www.5etdemi.com/blog/archives/2006/12/as3-png-encoder-
faster-better/) which you might be merging with.

All the details are here:
http://blog.modp.com/2007/08/adding-metadata-to-actionscript-3-png.html

You can see how to extract metadata via the command line here:
http://blog.modp.com/2007/08/editing-png-metadata-from-command-line.html

If you need to me to write unit tests or anything, please let me know.

Comments welcome

thanks,

--nickg

JSON doesn't recognize UINT (0x123456) as a number

Originally filed by [email protected] on 2007-09-18T23:13:35

What steps will reproduce the problem?

  1. Create a json string that contains a key:val like {"myNumber":0xFF1100}

What is the expected output? What do you see instead?
Should get the value (16716032), but parser throws an error "Unexpected 'x'
encountered'

What version of the product are you using? On what operating system?
corelib v.9

Please provide any additional information below.
I have provided a fix (lines 340-352, 538-547) in JSONTokenizer.as. See
attached.

Unable to Resolve "formatter" bundle

Originally filed by K2xL.com on 2008-02-22T14:58:00

What steps will reproduce the problem?

  1. Imported SWC
  2. Imported the XMLUtils library

What is the expected output? What do you see instead?
No errors. Two errors.

What version of the product are you using? On what operating system?
0.90. XP

Please provide any additional information below.

Enter one-line summary

Originally filed by joshspoon on 2007-04-26T06:40:00

What steps will reproduce the problem?

  1. attach source path
  2. copy and paste JSON example in the download
  3. Get error in Problems window: 1061: Call to a possibly undefined method
    decode through a reference with static type Class. JSON.mxml JSON line 14
    April 26, 2007 1:27:25 AM 2231

What is the expected output? What do you see instead?
No errors, Errors

What version of the product are you using? On what operating system?
I don't know but I checked for updates on subversion

Please provide any additional information below.

@playerversion asdoc tag should be 9.0 in source

Originally filed by mikechambers on 2007-01-10T07:44:51

All of the @playerversion AsDoc tags in the source specifies 8.5. I believe
this should be 9.0.

For example:

    /**
    *   Compares two arrays and returns a boolean indicating whether the arrays
    *   contain the same values at the same indexes.
    * 
    *   @param arr1 The first array that will be compared to the second.
    *
    *   @param arr2 The second array that will be compared to the first.
    *
    *   @return True if the arrays contains the same values at the same indexes.
        False if they do not.
    *
    *   @langversion ActionScript 3.0
    *   @playerversion Flash 8.5
    *   @tiptext
    */  

Enhancement: JSON deserializer shall take advantage of actionscript class typing

Originally filed by ma.qianfan on 2007-07-13T04:31:20

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.
JSON allows class hint and JSON deserializer shall allow users to request
returning object being strongly typed. Specifically, for example, when I
serialize a java object from server side, I could specify a corresponding
actionscript 3 class to use. Then on the client side I could get this
object instead of a generic object. When JSON serializer serializes an
actionscript object, the actionscript class shall also appear as a class hint.

Thank you very much!

Melvin
[email protected]

WSSEUsernameToken creates incorrect timestamp

Originally filed by epost001 on 2007-07-12T13:14:32

What steps will reproduce the problem?

  1. invoke WSSEUsernameToken.getUsernameToken("user", "password");

What is the expected output? What do you see instead?

The resulting string contains a string representation the date/time when
the function was called. The timezone of that string representation is Z
(for UTC), but the time itself is in local time.

What version of the product are you using? On what operating system?
as3corelib .90

Please provide any additional information below.

Suggested fix is to use DateUtil#toW3CDTF instead of the DateFormatter.

isWhiteSpace() in JSONTokenizer.as is only checking for 3 of the 4 white space characters

Originally filed by alanhkarp on 2007-07-12T23:23:27

What steps will reproduce the problem?

  1. Create a JSON string with '\r' as white space.
  2. Run JSON.decode on that string

What is the expected output? What do you see instead?

Should ignore '\r' as white space per RFC. Instead get parse error due to
unexpected character.

What version of the product are you using? On what operating system?

0.9 dated March 19. Windows XP

Please provide any additional information below.

Allow for decoding of non-quoted object identifier strings in a non-strict decode mode

Originally filed by marcinhow on 2007-09-04T12:50:55

What steps will reproduce the problem?

  1. private var string: String = '[[{metadata:{fields:
    [{width:50,attrname:"NME_NIVEL_FORM",fieldtype:"string"},
    {width:4,attrname:"ANO_FORM",fieldtype:"string"}]},rowdata:
    [["Doutorado","2006"]],version:2.0}]]';
  2. var obj: Object = JSON.decode(string);
  3. Error: Unexpected m encountered: because metadata shoud be "metadata"

What is the expected output? What do you see instead?
I would like of one array:
private var array: Array = [[{metadata:{fields:
[{width:50,attrname:"NME_NIVEL_FORM",fieldtype:"string"},
{width:4,attrname:"ANO_FORM",fieldtype:"string"}]},rowdata:
[["Doutorado","2006"]],version:2.0}]];

What version of the product are you using? On what operating system?
0.9

Order of objects lost during decode

Originally filed by evan.kaufman on 2008-04-04T22:44:57

What steps will reproduce the problem?

  1. Call JSON.decode() on JSON object containing several elements
  2. View or traverse structure of resultant Object (ie: with thunderbolt and
    firebug)

What is the expected output? What do you see instead?
Ordering of AS3 objects is inconsistent with order of JSON objects.

What version of the product are you using? On what operating system?
SVN revision 42, in Flash CS3 on Mac OS X 10.5.2

Please provide any additional information below.
I've attached an example fla and as files that demonstrate the problem.
(Requires viewing in Firefox w/ firebug to see the debug messages in the
console.)

I searched for any existing issues and didn't see any. I'm not sure if AS3
objects even hold specific order when iterating through them, so this may
be a lost cause. At any rate, I'd still like to know for sure.

DateUtil.parseW3CDTF - day is not parsed?

Originally filed by jason.grey.work on 2007-07-25T17:35:05

What steps will reproduce the problem?

var d:Date = DateUtil.parseW3CDTF("2007-07-25T16:12:00-06:00");
trace(d.day);

What is the expected output? What do you see instead?

expect 25, I always get 0 though.

What version of the product are you using? On what operating system?

0.90, on Windows XP

[Question] Decodes a JSON string into a XML object.

Originally filed by liangzhongmin on 2008-01-30T10:16:22

My System:

Flex Builder 2.0.1
as3corelib version: Release version .90

Code: Decodes a JSON string into a Array object.
package
{

import flash.display.Sprite;
import com.adobe.serialization.json.JSON;
import flash.xml.XMLDocument;
public class JSonTest extends Sprite
{
    public function JSonTest(){
      var object:Object=JSON.decode

('[{"title":"MTEnclosures","url":"http:www.ev123.com"}]');
var xm:Array=(object as Array);
trace("xm="+xm[0].title);
}
}
}
Code: Decodes a JSON string into a XML object.
package
{

import flash.display.Sprite;
import com.adobe.serialization.json.JSON;
import flash.xml.XMLDocument;
public class JSonTest extends Sprite
{
    public function JSonTest(){
      var object:Object=JSON.decode

('[{"title":"MTEnclosures","url":"http:www.ev123.com"}]');
var xm:XML=(object as XML);
trace("xm="+xm);
}
}
}

Result: xm=null

JSON decode cannot parse $ in object parameters

Originally filed by walkerford on 2008-05-29T06:22:42

What steps will reproduce the problem?

  1. if you have a string to decode like: "{$name: 'jon', $gender: 'male'}", where one of the parameters
    begins with a $, the dollar sign causes a parseError during JSON.decode.

What is the expected output? What do you see instead?
$ is a valid character in a parameter name and should be parsed. (We are using it as a namespace.)

What version of the product are you using? On what operating system?
Revision 42, Mac OSX Leopard with latest Safari

DateUtil.parseW3CDTF has small bug with time of 00:00:00

Originally filed by [email protected] on 2008-02-24T16:19:12

What steps will reproduce the problem?

  1. Call DateUtil.parseW3CDTF("2008-01-22T00:00:00Z")

What is the expected output? What do you see instead?
Result date is correct, but time is 7:00PM
Time should be 12:00 AM (midnight)

What version of the product are you using? On what operating system?
Not sure what version. I grabbed from svn February 23, 2008. Windows
Vista Business

Please provide any additional information below.
I fixed the issue, actually two issues, by modifying DateUtil.parseW3CDTF
to now look like the following. I commented my changes.

First change is changing the order of looking for the offset and placing
Zulu last and the default. This is because some Java libraries leaves off
the "Z" when no offset.

Second change is changing the way utc is calculated. It gave the incorrect
result when time is midnight. I changed to simply create a Date object and
let the Date object calculate utc instead of the code.

Here is the full parseW3CDTF method:
public static function parseW3CDTF(str:String):Date
{
var finalDate:Date;
try
{
var dateStr:String = str.substring(0, str.indexOf("T"));
var timeStr:String = str.substring(str.indexOf("T")+1, str.length);
var dateArr:Array = dateStr.split("-");
var year:Number = Number(dateArr.shift());
var month:Number = Number(dateArr.shift());
var date:Number = Number(dateArr.shift());

            var multiplier:Number;
            var offsetHours:Number;
            var offsetMinutes:Number;
            var offsetStr:String;

            // Modified by Dale Bronk for SpectrumK12.  Changed order of finding

offset.
// First check for "+", then "-", then assume "Z". This covers the
instances
// when "Z" is left off of the date string as some Java libraries will
not add
// the "Z" when Zulu or no offset.
// if (timeStr.indexOf("Z") != -1)
// {
// multiplier = 1;
// offsetHours = 0;
// offsetMinutes = 0;
// timeStr = timeStr.replace("Z", "");
// }
// else if (timeStr.indexOf("+") != -1)
// {
// multiplier = 1;
// offsetStr = timeStr.substring(timeStr.indexOf("+")+1, timeStr.length);
// offsetHours = Number(offsetStr.substring(0, offsetStr.indexOf(":")));
// offsetMinutes = Number(offsetStr.substring(offsetStr.indexOf(":")+1,
offsetStr.length));
// timeStr = timeStr.substring(0, timeStr.indexOf("+"));
// }
// // Modified by Dale Bronk for Spectrumk12. Next line use to be
simply "else", now "else if..."
// else if (timeStr.indexOf("-") != -1) // offset is -
// {
// multiplier = -1;
// offsetStr = timeStr.substring(timeStr.indexOf("-")+1, timeStr.length);
// offsetHours = Number(offsetStr.substring(0, offsetStr.indexOf(":")));
// offsetMinutes = Number(offsetStr.substring(offsetStr.indexOf(":")+1,
offsetStr.length));
// timeStr = timeStr.substring(0, timeStr.indexOf("-"));
// }
if (timeStr.indexOf("+") != -1)
{
multiplier = 1;
offsetStr = timeStr.substring(timeStr.indexOf("+")+1, timeStr.length);
offsetHours = Number(offsetStr.substring(0, offsetStr.indexOf(":")));
offsetMinutes = Number(offsetStr.substring(offsetStr.indexOf(":")+1,
offsetStr.length));
timeStr = timeStr.substring(0, timeStr.indexOf("+"));
}
else if (timeStr.indexOf("-") != -1)
{
multiplier = -1;
offsetStr = timeStr.substring(timeStr.indexOf("-")+1, timeStr.length);
offsetHours = Number(offsetStr.substring(0, offsetStr.indexOf(":")));
offsetMinutes = Number(offsetStr.substring(offsetStr.indexOf(":")+1,
offsetStr.length));
timeStr = timeStr.substring(0, timeStr.indexOf("-"));
}
else // No offset, assume Zulu
{
multiplier = 1;
offsetHours = 0;
offsetMinutes = 0;
timeStr = timeStr.replace("Z", "");
}

            var timeArr:Array = timeStr.split(":");
            var hour:Number = Number(timeArr.shift());
            var minutes:Number = Number(timeArr.shift());
            var secondsArr:Array = (timeArr.length > 0) ?

String(timeArr.shift()).split(".") : null;
var seconds:Number = (secondsArr != null && secondsArr.length > 0) ?
Number(secondsArr.shift()) : 0;
var milliseconds:Number = (secondsArr != null && secondsArr.length > 0)
? Number(secondsArr.shift()) : 0;

            // Modified by Dale Bronk for Spectrumk12.  Instead of calculating utc,

I now create a Date and let the
// Date object calculate utc. This is because the the original
calculation of utc was giving an incorrect
// result when the time was "00:00:00" which is midnight (12:00:00 AM).
finalDate = new Date(year, month, date, hour, minutes, seconds,
milliseconds);
var utc : Number = finalDate.getTime();
//var utc:Number = Date.UTC(year, month-1, date, hour, minutes,
seconds, milliseconds);

            var offset:Number = (((offsetHours * 3600000) + (offsetMinutes *

60000)) * multiplier);
finalDate = new Date(utc - offset);

            if (finalDate.toString() == "Invalid Date")
            {
                throw new Error("This date does not conform to W3CDTF.");
            }
        }
        catch (e:Error)
        {
            var eStr:String = "Unable to parse the string [" +str+ "] into a date. ";
            eStr += "The internal error was: " + e.toString();
            throw new Error(eStr);
        }
        return finalDate;
    }

JPGEncoder Poor Performance

Originally filed by trent.niemeyer on 2008-03-07T23:20:24

What steps will reproduce the problem?

  1. Initialize JPGEncoder (try various quality settings)
  2. Encode
  3. Track time spent encoding

What is the expected output? What do you see instead?
I would expect no more than a few seconds @ quality 70 for a 1MB x 1MB
picture (real imagery as opposed to cartoon or vector generated images)

What version of the product are you using? On what operating system?
.90, WinXP SP2

Please provide any additional information below.
Sample Image that took 21 seconds with image quality 70. (3.4 GHz Pentium
CPU, 1 GB RAM)
http://compression.ca/act/files/DSCN3974.jpg

JSON cannot encode class instance as String correctly

Originally filed by darron.schall on 2006-12-29T19:49:00

What steps will reproduce the problem?

  1. Create a simple class, like the following:

public class ExampleClass
{
public var prop1:String;
public var prop2:int;
}

  1. Attempt to get the jsonString from the class:

var instance:ExampleClass = new ExampleClass();
instance.prop1 = "test";
instance.prop2 = 42;
var jsonString:String = JSON.encode( instance );

  1. Output the jsonString value:

trace( jsonString ); // "{}"

What is the expected output? What do you see instead?

The expected output is the following string:
{"prop1":"test","prop2":42}

Please use labels and text to provide additional information.

The problem lies in the objectToString() method in JSONEncoder.as,
specifically line 248:

// loop over the keys in the object and add their converted
// values to the string
for ( var key:String in o ) {
...

That loop fails to iterate over the class members when o is a class instance.

The solution to the problem will need to use the describeType() method to
get the class meta data information, and then loop over that to create the
json string based on what the class members are.

Surce Download still has SVN info

Originally filed by jeremyx on 2007-01-26T20:38:58

What steps will reproduce the problem?

  1. Download the source
  2. Unzip and navigate to src directory
  3. Note that the .svn folders and meta-info still exist

What is the expected output? What do you see instead?

  • To not see this info. The source should be exported from SVN before
    uploading here.

DateUtil.parseRFC822 method coudl not analize date for as3corelib

Originally filed by yasukawa on 2008-03-24T12:43:19

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.

Issue decoding JSON strings created from Javascript

Originally filed by dinny.mathew on 2007-02-22T16:29:41

Trying to deserialize following JSON string generated from javscript but
getting parsing error.
[{BookTitle:"JSON", Name:"Mat"}]

But folloing JSON string can be serialized successfully:
[{"BookTitle":"JSON", "Name":"Mat"}]

Unit tests fails when timezone is not US-Pacific

Originally filed by darron.schall on 2007-01-15T21:11:56

The following unit tests are currently failing:

testParseW3CDTF
testParseW3CDTFWithMilliseconds
testParseRFC822

The reason that they're failing is because I'm running the test harness in
Eastern time, when the author wrotes the tests in Pacific time. The Date
object returned by the parse methods is correct, but the "hours" property
is not the same because the timezone offset factors into that value.

To fix, the hours comparison needs to factor in the time zone offset to
avoid erroneous test failures.

JSONDecoder needs to be more smart to parse

Originally filed by abdul.qabiz on 2007-08-29T08:51:45

Description:-

JSONDecoder class needs to be more smart to decode strings like this:-

[ { "ew" : "wahan", "hws" : [ "caa","sss", ] }, { "ew" : "aap", "hws" : [
"ss", ] }, ]

You can see, there is extra comma (,) in array and individual objects. I
know above example is result of logical-problem in JSON serialization, I
find it quite common and even some of Google API do that.

I patched the code so that it works even such cases. I am attaching bothing
the patch and changed file.

Expected:-

JSONDecoder should be able to parse improperly terminated strings as shown
above. Those are quite regular use-cases.

Actual:-

It throws ParseError when it encounters ] or } after comma (,) in an array
or object.

Support for Binary MD5 hash - code included

Originally filed by marklynch on 2008-01-14T11:37:55

It is not currently possible to create an MD5 hash of a Binary object - eg
for a image verification.

The code can support this functionality with only some minor changes and no
loss of backward compatibility.

I would really appreciate it if you could review these changes and include
them in the as3corelibs as I believe they are useful changes.

Regards,
Mark

Please find code attached.

Summary of code changes:

  • Rename hash function to be hashBinary.
  • Change parameters of hashBinary to accept a ByteArray
  • Change parameters of createBlocks to accept a ByteArray
  • Change createBlocks to use array reference instead of s.getCharCodeAt()
  • Create new hash() function which converts string to ByteArray and then
    call hashBinary passing in the ByteArray.

DateUtilTest - incorrect test - testParseRFC822()

Originally filed by sergey.bocharov on 2007-10-16T08:31:40

What steps will reproduce the problem?

  1. run default testsuite;

What is the expected output? What do you see instead?
[FAIL] testParseRFC822 - com.adobe.utils::DateUtilTest
Error: d.date == 5 - expected true but was false

What version of the product are you using? On what operating system?
as3corelib 0.9, windows vista, timezone +0300

Please provide any additional information below.
Suggested fix is to use -

assertTrue("d.dateUTC == 5",d.dateUTC == 5);
assertTrue("d.monthUTC == 11", d.monthUTC == 11);
assertTrue("d.fullYearUTC == 2005", d.fullYearUTC == 2005);
// Fixes issue #12 - use UTC so time zone doesn't throw off hours
assertTrue("d.hoursUTC == 22", d.hoursUTC == 22 );
assertTrue("d.minutesUTC == 55", d.minutesUTC == 55);
assertTrue("d.secondsUTC == 43", d.secondsUTC == 43);

instead of the -

assertTrue("d.date == 5",d.date == 5);
assertTrue("d.month == 11", d.month == 11);
assertTrue("d.fullYear == 2005", d.fullYear == 2005);
// Fixes issue #12 - use UTC so time zone doesn't throw off hours
assertTrue("d.hoursUTC == 22", d.hoursUTC == 22 );
assertTrue("d.minutes == 55", d.minutes == 55);
assertTrue("d.seconds == 43", d.seconds == 43);

@playerversion asdoc tag should be 9.0 in source

Originally filed by mikechambers on 2007-01-10T07:46:04

All of the @playerversion AsDoc tags in the source specifies 8.5. I believe
this should be 9.0.

For example:

    /**
    *   Compares two arrays and returns a boolean indicating whether the arrays
    *   contain the same values at the same indexes.
    * 
    *   @param arr1 The first array that will be compared to the second.
    *
    *   @param arr2 The second array that will be compared to the first.
    *
    *   @return True if the arrays contains the same values at the same indexes.
        False if they do not.
    *
    *   @langversion ActionScript 3.0
    *   @playerversion Flash 8.5
    *   @tiptext
    */  

JSON cannot decode Infinity or -Infinity

Originally filed by joe.nash.74 on 2007-08-17T12:06:02

What steps will reproduce the problem?

1. trace(JSON.decode(Infinity)); or
2. trace(JSON.decode(-Infinity));

What is the expected output? What do you see instead?

Expected output would be the same as the input: Infinity or
-Infinity.

Infinity error:

Error: Unexpected I encountered
at com.adobe.serialization.json::JSONTokenizer/parseError()
at com.adobe.serialization.json::JSONTokenizer/getNextToken()
at com.adobe.serialization.json::JSONDecoder/::nextToken()
at com.adobe.serialization.json::JSONDecoder$iinit()
at com.adobe.serialization.json::JSON$/decode()
at json_test_fla::MainTimeline/json_test_fla::frame1()

-Infinity error:

Error: Expecting a digit
at com.adobe.serialization.json::JSONTokenizer/parseError()
at com.adobe.serialization.json::JSONTokenizer/::readNumber()
at com.adobe.serialization.json::JSONTokenizer/getNextToken()
at com.adobe.serialization.json::JSONDecoder/::nextToken()
at com.adobe.serialization.json::JSONDecoder$iinit()
at com.adobe.serialization.json::JSON$/decode()
at json_test_fla::MainTimeline/json_test_fla::frame1()

What version of the product are you using? On what operating system?

Latest download. Windows XP, Flash CS3.

JSON doesn't decode with new lines

Originally filed by jlward4th on 2007-01-11T17:25:06

What steps will reproduce the problem?

  1. Create a JSON String with new lines after commas and after braces
  2. Try to decode it

What is the expected output? What do you see instead?
Error.

What version of the product are you using? On what operating system?
SVN - trunk

JSON example error

Originally filed by joshspoon on 2007-04-26T06:40:19

What steps will reproduce the problem?

  1. attach source path
  2. copy and paste JSON example in the download
  3. Get error in Problems window: 1061: Call to a possibly undefined method
    decode through a reference with static type Class. JSON.mxml JSON line 14
    April 26, 2007 1:27:25 AM 2231

What is the expected output? What do you see instead?
No errors, Errors

What version of the product are you using? On what operating system?
I don't know but I checked for updates on subversion

Please provide any additional information below.

JSON cannot encode class instance as String correctly

Originally filed by darron.schall on 2006-12-29T19:49:00

What steps will reproduce the problem?

  1. Create a simple class, like the following:

public class ExampleClass
{
public var prop1:String;
public var prop2:int;
}

  1. Attempt to get the jsonString from the class:

var instance:ExampleClass = new ExampleClass();
instance.prop1 = "test";
instance.prop2 = 42;
var jsonString:String = JSON.encode( instance );

  1. Output the jsonString value:

trace( jsonString ); // "{}"

What is the expected output? What do you see instead?

The expected output is the following string:
{"prop1":"test","prop2":42}

Please use labels and text to provide additional information.

The problem lies in the objectToString() method in JSONEncoder.as,
specifically line 248:

// loop over the keys in the object and add their converted
// values to the string
for ( var key:String in o ) {
...

That loop fails to iterate over the class members when o is a class instance.

The solution to the problem will need to use the describeType() method to
get the class meta data information, and then loop over that to create the
json string based on what the class members are.

JSON does not encode XML instances into anything useful

Originally filed by darron.schall on 2006-12-29T21:02:09

What steps will reproduce the problem?

  1. trace( JSON.encode( ) );

What is the expected output? What do you see instead?

Like Date instance (see issue #2), there is no standard XML encoding syntax
defined for JSON. Because E4X is a core part of ECMAScript Edition 4, I
would suspect that the JSON-encoded XML would just use <> like an XML literal.

So, the above trace would produce the following JSON string:

"<test attr1="test" attr2="42"><child1 childAttr1="false" />"

Along the same lines, the following:

var arr:Arary = new Array();
arr.push( );
arr.push( true );
trace( JSON.encode( arr ) );

... should probably output: "[,true]"

The current output is {}, which is clearly not good, no matter what the
expected output should be.

Please use labels and text to provide additional information.

There needs to be a consensus on what the expected output should be before
this is addressed.

This could spring into a religious debate, "Why on earth would anyone want
to encode XML in JSON? It's apples and oranges!"... but rather than get
into politics, I'd rather just agree on a universal solution / standard for
dealing with XML instances in JSON encoding.

parseW3CDTF and parseRFC822 should not accept dates that aren't formatted correctly

Originally filed by philoQE on 2007-01-25T22:50:50

What steps will reproduce the problem?

  1. use parseRFC822 to parse a date whose month is not 2 digits
    ex) DateUtil.parseRFC822(2007-1-243T04:00:00Z)

Similar cases for year, date, hour, etc. and also for parseW3CDTF

What is the expected output? What do you see instead?
Expected: error Actual: the dates are being accepted

What version of the product are you using? On what operating system?
Windows XP

Please provide any additional information below.
Attached is a Flex app that demonstrates the problem. This was originally
found in Philo

Add UnitTest for JPGEncoder class

Originally filed by mikechambers on 2007-01-10T08:27:35

We need to add a unit test for the JPGEncoder class:

com.adobe.images.JPGEncoder

URIError when URI component is not propertly UTF-8 encoded in URI class

Originally filed by philoQE on 2007-07-30T23:56:02

What steps will reproduce the problem?

Add this code to URITest.as in corelib:

public function testUnescapingUnencodedChars() : void

        {

              var s:String = "http://test.com/&&!%~ +=";

              assertTrue(URI.unescapeChars(s) == s);

        }

What is the expected output? What do you see instead?

Brian comments: "The problem is in corelib's com.adobe.net.URI class.
Specifically, URI.unescapeChars calls the global decodeURIComponent, which
throws a URIError because the URI component is not properly UTF-8 encoded.
A reasonable solution is to put the call to decodeURIComponent within a
try-catch block and return the passed-in value if the call throws, perhaps
parametrize this with a throwIfIllegal param, which the URI getters should
set to false."

What version of the product are you using? On what operating system?
corelib-90.zip, Windows XP

Please provide any additional information below.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.