PHP 5.2.3 Released

The PHP development team would like to announce the immediate availability of PHP 5.2.3. This release continues to improve the security and the stability of the 5.X branch as well as addressing two regressions introduced by the previous 5.2 releases....

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:
< Prev   Next >