added json error check in fromJson method