Ext JS and the fun with Open Source licenses

There has been a lot of noise revolving around Ext JS and the open source license decisions. Under the original license (LGPL-ish) many thought that it wasn't actually an open source license at all. Jack changed to GPL last week when he announced ve...

Conform your JSON to ECMAScript 4 with JCON Print E-mail
User Rating: / 0

Oliver Steele is doing great work, and he has just released a gem called JCON which stands for JavaScript Conformance. It tests JSON values to make sure that they are valid for the new world of ECMAScript 4 type definitions (e.g. new { x:int, y:string }( 3, "foo" ) ).


    type = JCON::parse "[string, int]"
    type.contains?([?a?, 1])     # => true
    type.contains?([?a?, ?b?])   # => false
    type.contains?([?a?, 1, 2])  # => true

    // via RSpec
    [1, ?xyzzy?].should conform_to_js(?[int, string]?)
    [1, 2, ?xyzzy?].should_not conform_to_js(?[int, string]?)  # 2 isn?t a string
    {:x => 1}.should conform_to_js(?{x: int}?)

    // with JavaScript Fu
    # this will succeed if e.g. response contains a script tag that includes
    #   fn("id", {x:1, y:2}, true)
    response.should call_js(?fn?) do |args|
      args[0].should conform_to_js(?string?)
      args[1].should conform_to_js(?{x:int, y:int}?)
      args[2].should conform_to_js(?boolean?)
      # or:
      args.should conform_to_js(?[string, {x:int, y:int}, boolean]?)

In other JSON news, it appears that new ECMAScript standard will no longer reserve the words:

abstract boolean byte char double final float implements int interface
long native package private protected public short static synchronized
throws transient volatile

And Douglas Crockford says that no browsers reserve them, and thus he is unreserving them from jsLint.

Read more at: http://feeds.feedburner.com/~r/ajaxian/~3/272812356/conform-your-json-to-ecmascript-4-with-jcon.
< Prev   Next >