Decode to text before writing to JSON (fixes #1)