Changed how packet bodies are built.

It's a bit tedious at times, but this is more flexible in special case
situations (ex. when a type integer needs to be a type string).
Incidentally, also removed the now unnecessary convertJSONTypes()
function.