Anonymous avatar Anonymous committed 0ed3b2a Draft

Made dumps and loads pass any optional arguments to the underlying implementation

Comments (0)

Files changed (1)

anyjson/__init__.py

         __import__(modname)
         return sys.modules[modname]
 
-    def dumps(self, data):
+    def dumps(self, data, *args, **kwargs):
         """Serialize the datastructure to json. Returns a string. Raises
         TypeError if the object could not be serialized."""
         try:
-            return self._encode(data)
+            return self._encode(data, *args, **kwargs)
         except self._encode_error, exc:
             raise TypeError, TypeError(*exc.args), sys.exc_info()[2]
     serialize = dumps
 
-    def loads(self, s):
+    def loads(self, s, *args, **kwargs):
         """deserialize the string to python data types. Raises
         ValueError if the string could not be parsed."""
         # uses StringIO to support buffer objects.
         try:
             if self._filedecode and not isinstance(s, basestring):
-                return self._filedecode(StringIO(s))
-            return self._decode(s)
+                return self._filedecode(StringIO(s), *args, **kwargs)
+            return self._decode(s, *args, **kwargs)
         except self._decode_error, exc:
             raise ValueError, ValueError(*exc.args), sys.exc_info()[2]
     deserialize = loads
         raise ImportError("No supported JSON module found")
 
 
-    def loads(value):
+    def loads(value, *args, **kwargs):
         """Serialize the object to JSON."""
-        return implementation.loads(value)
+        return implementation.loads(value, *args, **kwargs)
     deserialize = loads   # compat
 
 
-    def dumps(value):
+    def dumps(value, *args, **kwargs):
         """Deserialize JSON-encoded object to a Python object."""
-        return implementation.dumps(value)
+        return implementation.dumps(value, *args, **kwargs)
     serialize = dumps
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.