Jasonette / JASONETTE-Android

📡 Native App over HTTP, on Android
https://www.jasonette.com
Other
1.61k stars 270 forks source link

JSON parsing differences between iOS and Android #227

Open guidolang opened 6 years ago

guidolang commented 6 years ago

JSON parsing from a web API is handled differently on iOS and Android. Apparently the problem occurs when an API returns JSON code but no "application/json" content type declaration. See short example demonstrating the problem (and workaround) at https://www.jasonbase.com/things/Wxzm.json

gliechtenstein commented 6 years ago

I tried this a couple of hours ago when it wasn't working and confirmed that the app was failing. Then I headed out for a bit, then came back and sat down to work on the problem.

By then, for some reason the problem was gone. It's now loading just fine and the app is loading fine.

The only difference I am seeing is how the coindesk api was returning the malformed JSON earlier, but not anymore.

I tried to replicate this by saving the JSON as a text file https://s3-us-west-2.amazonaws.com/fm.ethan.jason/price.txt but even this seems to be working.

My only guess is that the coindesk api was messing up something and returning some corrupt data that looked like JSON but actually wasn't.

Can you still replicate this?

guidolang commented 6 years ago

Yes, I can still replicate the original error.

I created two Jason files to showcase the issue in more detail: one works on iOS but fails on Android (it displays {{JSON.parse($jason).bpi.USD.rate}}) (see https://www.jasonbase.com/things/rzD2.json); the other works on Android but fails on iOS (it displays a blank screen) (see https://www.jasonbase.com/things/53op.json).

However, the issue appears unrelated to the CoinDesk API. It seems that Android doesn't process the JSON.parse() method at all. I created another Jason file using a different API that works on iOS but fails on Android (it displays {{JSON.parse($jason)[0].title}}) (see https://www.jasonbase.com/things/ERYn.json).