JSON generator code moved out of Http Server