The following code is working perfectly for the json has more than one elements but when it encountered single element, it is failing and throwing the following exception.