Пример #1
0
    def test_set_preferred_backend_allows_magic(self):
        """Tests that we can use the pluggable backends magically
        """
        backend = 'os.path'
        jsonpickle.load_backend(backend, 'split', 'join', AttributeError)
        jsonpickle.set_preferred_backend(backend)

        slash_hello, world = jsonpickle.encode('/hello/world')
        jsonpickle.remove_backend(backend)

        self.assertEqual(slash_hello, '/hello')
        self.assertEqual(world, 'world')
Пример #2
0
    def test_set_preferred_backend_allows_magic(self):
        """Tests that we can use the pluggable backends magically
        """
        backend = 'os.path'
        jsonpickle.load_backend(backend, 'split', 'join', AttributeError)
        jsonpickle.set_preferred_backend(backend)

        slash_hello, world = jsonpickle.encode('/hello/world')
        jsonpickle.remove_backend(backend)

        self.assertEqual(slash_hello, '/hello')
        self.assertEqual(world, 'world')
Пример #3
0
    def test_set_preferred_backend_allows_magic(self):
        """Tests that we can use the pluggable backends magically
        """
        backend = "os.path"
        jsonpickle.load_backend(backend, "split", "join", AttributeError)
        jsonpickle.set_preferred_backend(backend)

        slash_hello, world = jsonpickle.encode("/hello/world")
        jsonpickle.remove_backend(backend)

        self.assertEqual(slash_hello, "/hello")
        self.assertEqual(world, "world")
Пример #4
0
import jsonpickle

# pylint: disable=unused-variable, unused-argument

jsonpickle.remove_backend("demjson")
jsonpickle.set_preferred_backend("json")

def dumps(obj, **args):
    return jsonpickle.encode(obj, unpicklable=False)

def loads(json, **args):
    return jsonpickle.decode(json)
Пример #5
0
import jsonpickle

# pylint: disable=unused-variable, unused-argument

jsonpickle.remove_backend("demjson")
jsonpickle.set_preferred_backend("json")


def dumps(obj, **args):
    return jsonpickle.encode(obj, unpicklable=False)


def loads(json, **args):
    return jsonpickle.decode(json)