Problem with JSON file?

4

I'm following a tutorial on how to create a gallery on android with glide and the information is in a file .json the code looks like this

[{
"name": "Deadpool",
"url": {
    "small": "http://api.androidhive.info/images/glide/small/deadpool.jpg",
    "medium": "http://api.androidhive.info/images/glide/medium/deadpool.jpg",
    "large": "http://api.androidhive.info/images/glide/large/deadpool.jpg"
},
"timestamp": "February 12, 2016"
},
{
"name": "Batman vs Superman",
"url": {
    "small": "http://api.androidhive.info/images/glide/small/bvs.png",
    "medium": "http://api.androidhive.info/images/glide/medium/bvs.png",
    "large": "http://api.androidhive.info/images/glide/large/bvs.png"
},
"timestamp": "March 25, 2016"
}]

but when changing the direction of the images for example by some image of my android studio I'm getting this error

11-01 15:12:13.358 26978-26978/com.example.android.ejemplo E/MainActivity:    Error: org.json.JSONException: Value <html> of type java.lang.String cannot be converted to JSONArray

the .json file has to "link" with some html file ?? or because the error ?, I hope your help, thanks.

    
asked by SpaceSpace 01.11.2016 в 22:46
source

2 answers

0

Reviewing your error:

  

Error: org.json.JSONException: Value of type java.lang.String   can not be converted to JSONArray

refers to a "<html>" , possibly the error is that the url is incorrect, it ensures to actually provide a url with content '.json.

Another reason is that probably when editing your file is not properly formed.

    
answered by 01.11.2016 в 23:39
-2

you could try this:

[{
    "name": "Deadpool",
    "url": [{
        "small": "http://api.androidhive.info/images/glide/small/deadpool.jpg",
        "medium": "http://api.androidhive.info/images/glide/medium/deadpool.jpg",
        "large": "http://api.androidhive.info/images/glide/large/deadpool.jpg"
    }],
    "timestamp": "February 12, 2016"
}, {
    "name": "Batman vs Superman",
    "url": [{
        "small": "http://api.androidhive.info/images/glide/small/bvs.png",
        "medium": "http://api.androidhive.info/images/glide/medium/bvs.png",
        "large": "http://api.androidhive.info/images/glide/large/bvs.png"
    }],
    "timestamp": "March 25, 2016"
}]

I think that the brackets are missing to arm in arrangement in this part:

"url": {
    "small": "http://api.androidhive.info/images/glide/small/deadpool.jpg",
    "medium": "http://api.androidhive.info/images/glide/medium/deadpool.jpg",
    "large": "http://api.androidhive.info/images/glide/large/deadpool.jpg"
}, 

I hope this change helps you.

    
answered by 20.01.2017 в 16:26