Extract JSON loading code as a class