Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

missing JSON libraries for Google App Engine application?

I recently purchased a copy of Practical Android Projects. Chapter 8 talks about how to use Google App Engine with Android. It gives as an example (source code available here in the folders PracticalAndroidProjectsSourceCode/Projects/08_GameManager and 08_GameService) an Android application which consumes a web service from an App Engine application.

I haven't been able to get the example App Engine application (which provides the service) to run correctly. The problem is that the application expects JSON libraries which aren't available. I've tried downloading JSON libraries from elsewhere on the web as JAR files and including them in the application. (See discussion.) This hasn't worked, because none of the JSON libraries I've tried seem to be fully compatible with the libraries it's expecting.

I'm new to Android and GAE development, and as such these problems are daunting to me; I've spent days trying to find a solution. Anybody want to take a crack at this problem? If I do find a solution, I will post it here so anybody else who purchased the book will be able to run this example!

Are you able to run this example on your machine? I'm using Eclipse as my IDE.

like image 260
Asher Walther Avatar asked Jul 06 '26 19:07

Asher Walther


1 Answers

I don't know that book and you didn't show the exact code you tried, but the name of the JSON library varies depending on which runtime version (in app.yaml) you use. For Python (== Python 2.5), use simplejson. For Python 2.7, use plain json. The following example straightens out the differences for the rest of your code:

try:
    import json
except ImportError:
    inport simplejson as json

Now in the rest of your code you can always use json.dumps() and json.loads().

like image 152
Guido van Rossum Avatar answered Jul 09 '26 09:07

Guido van Rossum



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!