Commit 05050e4b authored by James Page's avatar James Page

Replace ujson with json

ujson has not had any active maintenance for the last 12 months;
switch to using json module instead.

Change-Id: I39027b534e94b3f877d881647a7c843183f60f92
Closes-Bug: 1737989
parent a6da5a6b
......@@ -15,6 +15,7 @@
from collections import defaultdict
import hashlib
import itertools
import json
import operator
import pkg_resources
import threading
......@@ -28,7 +29,6 @@ from oslo_utils import timeutils
import six
import six.moves.urllib.parse as urlparse
from stevedore import extension
import ujson
from ceilometer import declarative
from ceilometer import gnocchi_client
......@@ -502,7 +502,7 @@ class GnocchiPublisher(publisher.ConfigPublisherBase):
def _search_resource(self, resource_type, query):
try:
return self._gnocchi.resource.search(
resource_type, ujson.loads(query))
resource_type, json.loads(query))
except Exception:
LOG.error("Fail to search resource type %{resource_type}s "
"with '%{query}s'",
......
......@@ -13,12 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
import json
from oslo_log import log
from oslo_utils import strutils
import requests
from requests import adapters
from six.moves.urllib import parse as urlparse
import ujson
from ceilometer import publisher
......@@ -154,7 +155,7 @@ class HttpPublisher(publisher.ConfigPublisherBase):
if not data:
LOG.debug('Data set is empty!')
return
data = ujson.dumps(data)
data = json.dumps(data)
LOG.trace('Message: %s', data)
try:
res = self.session.post(self.target, data=data,
......
......@@ -13,11 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
import json
from six.moves.urllib import parse as urllib
from tempest import config
from tempest.lib.common import rest_client
from tempest import manager
import ujson
CONF = config.CONF
......@@ -28,10 +29,10 @@ class AlarmingClient(rest_client.RestClient):
uri_prefix = "v2"
def deserialize(self, body):
return ujson.loads(body.replace("\n", ""))
return json.loads(body.replace("\n", ""))
def serialize(self, body):
return ujson.dumps(body)
return json.dumps(body)
def list_alarms(self, query=None):
uri = '%s/alarms' % self.uri_prefix
......
......@@ -260,5 +260,5 @@ class TestHttpPublisher(base.BaseTestCase):
with mock.patch.object(requests.Session, 'post') as post:
publisher.publish_events(self.event_data)
self.assertEqual(
'[{"some":"aa"},{"some":"aa"},{"some":"aa"}]',
'[{"some": "aa"}, {"some": "aa"}, {"some": "aa"}]',
post.call_args[1]['data'])
......@@ -14,8 +14,9 @@
# under the License.
"""Tests for ceilometer/publisher/utils.py
"""
import json
from oslotest import base
import ujson
from ceilometer.publisher import utils
......@@ -104,7 +105,7 @@ class TestSignature(base.BaseTestCase):
data['message_signature'] = utils.compute_signature(
data,
'not-so-secret')
jsondata = ujson.loads(ujson.dumps(data))
jsondata = json.loads(json.dumps(data))
self.assertTrue(utils.verify_signature(jsondata, 'not-so-secret'))
def test_verify_unicode_symbols(self):
......@@ -114,7 +115,7 @@ class TestSignature(base.BaseTestCase):
data['message_signature'] = utils.compute_signature(
data,
'not-so-secret')
jsondata = ujson.loads(ujson.dumps(data))
jsondata = json.loads(json.dumps(data))
self.assertTrue(utils.verify_signature(jsondata, 'not-so-secret'))
def test_verify_no_secret(self):
......
......@@ -19,7 +19,6 @@ oslo.reports>=0.6.0 # Apache-2.0
oslo.rootwrap>=2.0.0 # Apache-2.0
pbr>=1.6 # Apache-2.0
oslo.messaging>=5.12.0 # Apache-2.0
ujson
oslo.utils>=3.5.0 # Apache-2.0
pysnmp<5.0.0,>=4.2.3 # BSD
python-glanceclient>=2.0.0 # Apache-2.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment