JS client: split out json/rjr conversion into helper methods