switching json keys; fixing potential null pointer