Corrected the JSON parsing and added space handling