Fixed conversion of types to JSON