use JSON serialization, rather than not-to-spec string interpolation

The string interpolation was causing bugs on the iOS end, due to
embedded newlines in the data string.