import json


class OneLine:
    """Wrap any value in this class to print it on one line in the JSON file"""

    def __init__(self, value):
        self.value = value


def dumps(obj, indent: int = 2, _level: int = 0) -> str:
    """
    Encode an object hierarchy as JSON string. In addition to
    what json.dumps in the standard library provides, this function
    allows to disable indentation for selected parts of the hierarchy
    by marking lists or dicts with the "OneLine" class.

    Arguments:
        obj: object to encode
        indent: indentation level

    >>> print(dumps({"a": [1, 2], "b": OneLine([3, 4]), "c": dict(x=5, y=6), "d": OneLine(dict(x=7, y=8))}))
    {
      "a": [
        1,
        2
      ],
      "b": [3, 4],
      "c": {
        "x": 5,
        "y": 6
      },
      "d": {"x": 7, "y": 8}
    }
    """
    if isinstance(obj, (float, int, str, bool, OneLine)) or obj is None:
        if isinstance(obj, OneLine):
            obj = obj.value
        return json.dumps(obj)

    start = "\n" + (_level + 1) * indent * " "
    sep = "," + start
    end = "\n" + _level * indent * " "
    if isinstance(obj, (tuple, list)):
        return (
            "["
            + start
            + sep.join(dumps(elem, indent, _level + 1) for elem in obj)
            + end
            + "]"
        )
    elif isinstance(obj, dict):
        return (
            "{"
            + start
            + sep.join(json.dumps(k) + ": " + dumps(v, indent, _level + 1) for k, v in obj.items())
            + end
            + "}"
        )
    else:
        raise ValueError(f"cannot serialize type {obj.__class__.__name__}")

@@ -829,24 +829,82 @@
 %7D%0A    %7D%0A
+    %3E%3E%3E print(dumps(%7B%22a%22: %5B%5D%7D))%0A    %7B%0A      %22a%22: %5B%5D%0A    %7D%0A
     %22%22%22%0A
     if i
@@ -891,24 +891,24 @@
   %7D%0A    %22%22%22%0A
-
     if isins
@@ -1212,16 +1212,60 @@
 list)):%0A
+        if not obj:%0A            return %22%5B%5D%22%0A
         
@@ -1423,24 +1423,24 @@
 %22%0A        )%0A
-
     elif isi
@@ -1459,16 +1459,60 @@
  dict):%0A
+        if not obj:%0A            return %22%7B%7D%22%0A
         

Fix JSON serialization