more code porting to new WriteJSON format