December 2008 Archives

AS3 JSON library now a little less strict

| No Comments | No TrackBacks
I've just checked in revision 83 of as3corelib that adds a strict flag to the AS3 JSON library.  In the past the library would generate an error if the JSON string was deemed invalid according to the syntax rules.  Now, based on the strict flag setting, the parser does a better job at allowing "valid" input even if the input doesn't match the JSON spec.

I've actually had this code completed since MAX 2008.  I wrote it on my flight from San Fransisco to Harrisburg, but haven't had the time to get it ready for check-in until now.

Here is the commit message:

  • Added throwing error if entire string cannot be consumed (when there are remaining characters left in the input stream)
  • Added "strict" flag to decoding process.  Default is true for backwards compatibility.  When false, relaxes input format rules.  Fixes #34, Fixes #41, Fixes #71:
    • Allows for hex specification for numbers, ex: { "myNum": 0xFFCC33 }
    • Allows for NaN to be parsed as a number, ex: { "myNum": NaN }
    • Allows for trailing commas in arrays, ex: [1,2,]
    • Allows for trailing commas in objects, ex: { "p1":true, "p2":false, }
    • Does not throw error if there were characters left in the input string
  • Added tests for strict flag
  • Added tests to better exercise comments
  • Updated tests to use proper assert types
  • Some minor cosmetic code cleanup
Usage is exactly the same as before, with the additional option of specifying the strict flag as part of the JSON.decode( string, strict ) call.  Example:

// Set strict mode to false to allow for trailing commas to not throw an error
var o:Array = JSON.decode( "[0,1,]", false ) as Array;
assertEquals( 0, o[0] );
assertEquals( 1, o[1] );

// Same usage as before, strict mode will throw a runtime error if the string is not valid
var a:Array = JSON.decode( "[0,1,]" ) as Array;

I still need to address #35 to allow for unquoted keys in objects to be parsed in non-strict mode.  This is a bit more complicated of a change because it changes how the tokenizer recognizes what is in the input stream.  It's coming though!

Note that a new .swc file was not yet posted.  If you want to experiment with these changes, you'll have to pull the latest from source.  I'll work with Mike to get the download .swc updated soon.

Hello World 2.0

| No Comments | No TrackBacks
It's been about a year since I've last posted something.  Pardon the dust...  it's not that I haven't had anything to say, it's more that I just haven't had the time to say it.

In fact, I've neglected my weblog so much that I had to upgrade through not just one but two major versions of MovableType.  It was interesting upgrading from 2.6 to 3.35 to 4.21 then finally to the latest 4.23.  The upgrade from 2.6 to 3.35 was smooth, but 3.35 to 4.21 was an epic fail.

Years and years ago when I first created my weblog I chose Berkeley DB as my database option.  I would've chosen MySQL but at the time either my host didn't support it or MT didn't support it, I don't really remember.  Today, it turns out that Brekeley DB is no longer supported in modern versions of MT.

I lost basically everything during the 3.35 to 4.21 upgrade when my database became unreadable.  I had some backups that I was able to use to import all of my old entries and comments without too much issue, but I wasn't able to recover the site design.  I had customized the default MT templates to leverage my ColdFusion custom tag templating system that I createad for my website, but the MT templates have radically changed over the years.  Also, the CSS and page structure were too structurally different and I wasn't able to quickly/easily modify the default MT template to work with my past site design.  I'm not a huge fan of the default design I'm using now so I'm still working on getting my old site design back (but I expect that it's going to take quite a bit time).

Not only that, but I also lost my code coloring plugin.  In the past I've used MTCodeBeautifier but this no longer works with the MT4.  I've started using SyntaxHighlighter which is a completely JavaScript-based solution and should be future-proof, however, I haven't been through all of my old entries to convert them.  I'm still working on that, too...

Anyway, what I have been up to lately?

Well... I've been up to my elbows in Flex development.  It's been a great year and I've worked on some really interesting and challenging projects.  Perhaps the biggest news, though, is that my employment situation has changed.

I'm now officially employed by Universal Mind as a Principal Architect (and have been since the summer).  It feels great to be part of such an elite and passionate team.  I'm really excited about what the future holds for both myself and the company, and I'm especially happy to see the immense positive reaction that SpatialKey has been getting.

Now that I'm back up and running, in the future I hope to get through the backlog of weblog ideas that I've been meaning to post for... well... over a year now.  I'm just as busy as always but now that I actually have modern weblog software that can do things like schedule entry posting dates, it should be easier for me to stay on top of things.

Stay tuned...

Oh, one final note, my RSS feed link has changed to http://feedproxy.google.com/darronschall.  The old rdf link is no longer being updated.


About this Archive

This page is an archive of entries from December 2008 listed from newest to oldest.

January 2008 is the previous archive.

January 2009 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Archives

OpenID accepted here Learn more about OpenID
Powered by Movable Type 5.02