Be flexible where simplejson comes from
diff --git a/apiclient/discovery.py b/apiclient/discovery.py
index d15c5b2..5a0ba33 100644
--- a/apiclient/discovery.py
+++ b/apiclient/discovery.py
@@ -25,11 +25,20 @@
import logging
import os
import re
-import simplejson
import uritemplate
import urllib
import urlparse
+try:
+ import simplejson
+except ImportError:
+ try:
+ # Try to import from django, should work on App Engine
+ from django.utils import simplejson
+ except ImportError:
+ # Should work for Python2.6 and higher.
+ import json as simplejson
+
class HttpError(Exception):
pass
diff --git a/discovery_extras.py b/discovery_extras.py
index f8c1d30..c0b84ba 100644
--- a/discovery_extras.py
+++ b/discovery_extras.py
@@ -23,9 +23,19 @@
import os
import os.path
-import simplejson
import sys
+try:
+ import simplejson
+except ImportError:
+ try:
+ # Try to import from django, should work on App Engine
+ from django.utils import simplejson
+ except ImportError:
+ # Should work for Python2.6 and higher.
+ import json as simplejson
+
+
def main():
for filename in sys.argv[1:]:
f = file(filename, "r")
@@ -49,4 +59,3 @@
if __name__ == '__main__':
main()
-