refactor map JSON parsing code to getGraph function