More complicated solution to json encoding with str vs unicode.