Moved JSON parse code to it's own method.