Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
dfox426098yAlso wouldn't a check need to exist either way to see if attached_image is a non-false value?
-
@dfox {"id":124749,"text":"Just found out that if you request a rant with the API and the rant...","num_upvotes":1,"num_downvotes":1,"score":1,"created_time":1469821677,"attached_image": {},...}
It should be an empty object, two curly braces. The request returns "", which means empty string. -
@dfox It shouldn't come to a point where you need to check, not sure tho. If there is an object, the image exists, if not, the image doesnt. But returning an empty string is kinda against the API, because an image is defined as an object. So even the empty return value should be one.
-
@dfox But attached_image isn't a boolean value. Maybe I am getting it wrong tho. I am trying to map the son to Java Objects but the library messes me up. Image is defined as an object if it exists, so I mapped it to an Image class. But if there is no image, it is an empty string, which throws exceptions all over the place because the parser expects an object.
Don't want to be cocky or anything like that but the parser is right at this point. -
dfox426098y@SirWindfield I see what you're saying - this actually appears to be a bug (though it doesn't currently break anything). The expected behavior on our end, and what it seems he behavior was at some point, is there should be no attached_image on rants that don't have images.
I'll revert to that behavior (no attached_image property when there's no image) once I can confirm it doesn't break anything in our apps and some other community-created ones. I'll let you know a bit later.
Related Rants
Just found out that if you request a rant with the API and the rant doesn't contain an attached image, the 'attached_image' property defaults to an empty string, which is false, because an attached image is an object. This little thing screws up my code and I get exceptions all over the place D:
Mind fixing this? Or does anybody know how to tell Gson to allow an empty object field to be a string? Doesn't make a lot of sense though.
undefined
android
gson
json
fox
devrant