Metadata json support

This supercedes PR #334 from @cyberious. It includes his original commit + a fix for the spec test and an updated log message.