Minor flaw in JSON removed

edited the json code due to a minor error caused by a comma.
moved clutter to a function