Skip to content Skip to sidebar Skip to footer

Android Org.json.jsonexception: Value Of Type Java.lang.string Cannot Be Converted To Jsonobject

try { File yourFile = new File(Environment.getExternalStorageDirectory(), 'textarabics.txt'); FileInputStream stream = new FileInputStream(yourFile); String

Solution 1:

{"data":[{"id":"1","title":"Farhan Shah","duration":10,},{"id":"2","title":"Noman Shah","duration":10,},{"id":"3","title":"Ahmad Shah","duration":10,},{"id":"4","title":"Mohsin Shah","duration":10,},{"id":"5","title":"Haris Shah","duration":10,}]}

This JSON is invalid "duration": 10, there is an extra comma at the end. Remove that comma and try.

Remove that comma from every object. The modified JSON will look like this.

{"data":[{"id":"1","title":"Farhan Shah","duration":10},{"id":"2","title":"Noman Shah","duration":10},{"id":"3","title":"Ahmad Shah","duration":10},{"id":"4","title":"Mohsin Shah","duration":10},{"id":"5","title":"Haris Shah","duration":10}]}

Solution 2:

Post a Comment for "Android Org.json.jsonexception: Value Of Type Java.lang.string Cannot Be Converted To Jsonobject"