Changed output to be JSON when applicable.