JSON.framework v2.2 released!

I am proud to present version 2.2 of JSON.framework, the strict JSON parser/generator for Cocoa and the iPhone. You can get the latest version from the download page.

Here are the more significant changes from the 2.1 series:

  • New, fresh API—particularly for errors

    Extracted the SBJsonWriter and SBJsonParser classes from the SBJSON class. These present a fresh, simple API. If a method returns nil, you can now simply call a method to get an array of NSError objects containing the error trace.

    The SBJSON class is now a facade, implementing its old interface by forwarding messages to instances of the new classes. Additionally, the facade also implements the new simplified interface of the SBJsonWriter and SBJsonParser classes.

    The category methods on Foundation objects have also been re-implemented more efficiently in terms of the new objects. In case of error in these methods now print the full trace to the log, rather than just the top-level error.

  • Support for JSON representation of custom objects

    If you implement the -proxyForJson method in a custom class (either directly or as category) this now enables JSON.framework to create a JSON representation for objects of that type. See the ProxyTest.m file for more information on how this works.

  • Deprecated fragment-based methods

    The fragment-based methods are an extension to the JSON spec that does not belong in a strict JSON parser/generator. They were originally implemented to ease testing, but the tests should rather be rewritten not to need them. For the time being they are still included, but will be removed in the 2.3.x line.

  • Updated the iPhone SDK

    The iPhone SDK has had some updates to address problems some people were seeing. It has been updated to be based on iPhoneOS v2.2.1.

  • Fix crash on recursive structures

    Implemented the maxDepth setting for writing JSON. This defaults to 512 and means the framework won’t crash if its is fed a recursive (or extremely deeply nested) structure.

  • Documentation updates

    Simplified the installation instructions, particularly for the iPhone.

    In the API documentation classes now inherit documentation from their superclasses and the protocols they implement.

  • Miscellaneous

    Fixed some warnings reported by the Clang static analyser.

    Added a Changes file and updated the Credits.

Comments (9)

Doxygen and API docs in Subversion

For one of my projects I have just started checking generated API documentation into Subversion. This has a few benefits:

  • I don’t need separate hosting for the generated API documentation.
  • The API documentation benefits from whatever versioning scheme you adopt in Subversion.
  • By hooking the script into your release process you can make sure that the documentation is always up to date.

However, there’s a couple of things that may snag you too:

  • It requires that your Subversion repository is available over HTTP.
  • You have to set the mime-type of the various file types correctly. Otherwise you just get the raw content of each file.
  • You have to deal with adding and removing files when the documentation changes.
  • Doxygen puts a timestamp in every file so every time you regenerate the documentation all the files will appear to have changed. That’s a lot of unnecessary updates if you’re barely tweaking the version number for a patch release.

If you’re using Google Code your repository is already available over HTTP. The below script snippet deals with the remaining issues. It assumes that you have already run Doxygen and generated documentation in /tmp/doxygen, and that you are running it from your Subversion checkout, and that the directory that contains the API documentation is called apidocs.

rm -f apidocs/*
cp -p /tmp/doxygen/html/* apidocs
cd apidocs

# Revert files that only has one line removed
# and one added. They differ only in the timestamp.
svn diff *.html \
	| diffstat \
	| awk '$3 == 2 { print $1 }' \
	| xargs svn revert

# Add/remove files from subversion.
svn st | awk '
    $1 == "?" { print "svn add", $2 }
    $1 == "!" { print "svn delete",  $2 }
' | sh -

# Set mime-types so files display properly
# rather than just display their raw content.
svn propset svn:mime-type text/html *.html
svn propset svn:mime-type text/css *.css
svn propset svn:mime-type image/png *.png
svn propset svn:mime-type image/gif *.gif

Notice that it doesn’t actually submit the changes, so you can verify that the generated documentation looks like you want it to before you check it in.

Leave a Comment

iTunes Genius fail

Words don’t do it justice, so here’s a picture:

genius-fail.png

Comments (2)

Older Posts »