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.
Should this be an additional test instead of replacing the old line 1273?