Working loc2json function.