import json

from six import StringIO
from six import string_types
from six import integer_types


def _to_text(text, obj):
    if isinstance(obj, dict):
        for key in sorted(obj.keys()):
            _to_text(text, key)
            _to_text(text, obj[key])

    elif isinstance(obj, list):
        for item in obj:
            _to_text(text, item)

    elif isinstance(obj, string_types):
        text.write(obj)
        text.write(u' ')

    elif isinstance(obj, integer_types):
        text.write(str(obj))
        text.write(u' ')


def _get_file(f, **kwargs):
    text, obj = StringIO(), json.loads(f.read().decode('utf8'))

    _to_text(text, obj)

    return text.getvalue()

@@ -388,154 +388,135 @@
 ypes
-):%0A        text.write(obj)%0A        text.write(u' ')%0A%0A    elif isinstance(obj, integer_types):%0A        text.write(str(obj))%0A        text.write(u' '
+ + integer_types):%0A        text.write(u'%25s ' %25 obj)%0A%0A    else:%0A        raise ValueError('Unrecognized type: %25s' %25 obj.__class__
 )%0A%0A%0A
@@ -553,19 +553,20 @@
   text, 
-obj
+data
  = Strin
@@ -571,16 +571,35 @@
 ingIO(),
+ f.read()%0A    obj =
  json.lo
@@ -602,24 +602,20 @@
 n.loads(
-f.read()
+data
 .decode(

Use format string. Readability. ValueError.