Use JSON instead of manual string manipulation.