[autotest] Use |json| instead of |simplejson|.
simplejson was moved into the library as of python 2.4. We're now at
python 2.6/2.7, and having to keep installing simplejson everywhere has
slowly turned into a hassle. Since we can just trivially drop/rename
it, let's do so.
The rpc_interface parts of this change have been vetted, the rest is
done just as a s/simplejson/json/ across the code, which afaik should be
a safe thing to do.
BUG=None
TEST=unit, run_suite
DEPLOY=apache
Change-Id: Iab35f71157e7e5cd3be5291c776b07eb3283be8e
Reviewed-on: https://gerrit.chromium.org/gerrit/46424
Tested-by: Aviv Keshet <akeshet@chromium.org>
Reviewed-by: Alex Miller <milleral@chromium.org>
Commit-Queue: Aviv Keshet <akeshet@chromium.org>
diff --git a/frontend/shared/json_html_formatter.py b/frontend/shared/json_html_formatter.py
index b4b7364..6ef0736 100644
--- a/frontend/shared/json_html_formatter.py
+++ b/frontend/shared/json_html_formatter.py
@@ -29,7 +29,7 @@
"""
import re
-import simplejson
+import json
_HTML_DOCUMENT_TEMPLATE = """
<!DOCTYPE html>
@@ -134,7 +134,7 @@
if request.GET.get('alt', None) != 'json-html':
return response
- json_value = simplejson.loads(response.content)
+ json_value = json.loads(response.content)
html = JsonHtmlFormatter().json_to_html(json_value)
response.content = html
response['Content-type'] = 'text/html'
diff --git a/frontend/shared/resource_lib.py b/frontend/shared/resource_lib.py
index 86cc583..254e92f 100644
--- a/frontend/shared/resource_lib.py
+++ b/frontend/shared/resource_lib.py
@@ -3,7 +3,7 @@
import django.core.exceptions
from django.core import urlresolvers
from django.utils import datastructures
-import simplejson
+import json
from autotest_lib.frontend.shared import exceptions, query_lib
from autotest_lib.frontend.afe import model_logic
@@ -203,7 +203,7 @@
query_parameters = self._query_parameters_response()
if query_parameters:
content['query_parameters'] = query_parameters
- encoded_content = simplejson.dumps(content)
+ encoded_content = json.dumps(content)
return http.HttpResponse(encoded_content,
content_type=_JSON_CONTENT_TYPE)
@@ -214,7 +214,7 @@
raw_data = self._request.raw_post_data
if content_type == _JSON_CONTENT_TYPE:
try:
- raw_dict = simplejson.loads(raw_data)
+ raw_dict = json.loads(raw_data)
except ValueError, exc:
raise exceptions.BadRequest('Error decoding request body: '
'%s\n%r' % (exc, raw_data))
@@ -228,7 +228,7 @@
value = values[-1] # take last value if multiple were given
try:
# attempt to parse numbers, booleans and nulls
- raw_dict[key] = simplejson.loads(value)
+ raw_dict[key] = json.loads(value)
except ValueError:
# otherwise, leave it as a string
raw_dict[key] = value
diff --git a/frontend/shared/resource_test_utils.py b/frontend/shared/resource_test_utils.py
index 8cb742f..f52cd3b 100644
--- a/frontend/shared/resource_test_utils.py
+++ b/frontend/shared/resource_test_utils.py
@@ -1,5 +1,5 @@
import operator, unittest
-import simplejson
+import json
from django.test import client
from autotest_lib.frontend.afe import frontend_test_utils, models as afe_models
@@ -53,7 +53,7 @@
if 'data' in kwargs:
kwargs.setdefault('content_type', 'application/json')
if kwargs['content_type'] == 'application/json':
- kwargs['data'] = simplejson.dumps(kwargs['data'])
+ kwargs['data'] = json.dumps(kwargs['data'])
if uri.startswith('http://'):
full_uri = uri
@@ -72,7 +72,7 @@
return response.content
try:
- return simplejson.loads(response.content)
+ return json.loads(response.content)
except ValueError:
self.fail('Invalid reponse body: %s' % response.content)