We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
json2po output strings in wrong order
Running `json2po` outputs a valid PO files, but the strings are in the wrong order. I’m not sure exactly _which_ order it is, but is _neither_ the original order, the reverse order or alphabetically. Here’s an example JSON file:

``` json
{
    "foo": "foo",
    "bar": "bar",
    "baz": "baz"
}
```

Running `json2po` on this file results in the following (with a PO file header):

``` po
#: .baz
msgid "baz"
msgstr ""

#: .foo
msgid "foo"
msgstr ""

#: .bar
msgid "bar"
msgstr ""
```

Having the strings in a different order than in the original file makes it much harder to correctly translate the file, as one loses context.

I observe this bug both in version 1.13.0 and 1.14.0-rc1.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `translate/storage/jsonl10n.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright 2007,2009-2011 Zuza Software Foundation
4 #
5 # This file is part of the Translate Toolkit.
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, see <http://www.gnu.org/licenses/>.
19 
20 r"""Class that manages JSON data files for translation
21 
22 JSON is an acronym for JavaScript Object Notation, it is an open standard
23 designed for human-readable data interchange.
24 
25 JSON basic types:
26 
27 - Number (integer or real)
28 - String (double-quoted Unicode with backslash escaping)
29 - Boolean (true or false)
30 - Array (an ordered sequence of values, comma-separated and enclosed in square
31   brackets)
32 - Object (a collection of key:value pairs, comma-separated and enclosed in
33   curly braces)
34 - null
35 
36 Example:
37 
38 .. code-block:: json
39 
40    {
41         "firstName": "John",
42         "lastName": "Smith",
43         "age": 25,
44         "address": {
45             "streetAddress": "21 2nd Street",
46             "city": "New York",
47             "state": "NY",
48             "postalCode": "10021"
49         },
50         "phoneNumber": [
51             {
52               "type": "home",
53               "number": "212 555-1234"
54             },
55             {
56               "type": "fax",
57               "number": "646 555-4567"
58             }
59         ]
60    }
61 
62 
63 TODO:
64 
65 - Handle ``\u`` and other escapes in Unicode
66 - Manage data type storage and conversion. True --> "True" --> True
67 - Sort the extracted data to the order of the JSON file
68 
69 """
70 
71 import json
72 import os
73 try:
74     from collections import OrderedDict
75 except ImportError:
76     # Python 2.6 does not have OrderedDict and also can't use it in
77     # json.loads()
78     OrderedDict = None
79 import six
80 
81 from translate.storage import base
82 
83 
84 class JsonUnit(base.TranslationUnit):
85     """A JSON entry"""
86 
87     def __init__(self, source=None, ref=None, item=None, **kwargs):
88         self._id = None
89         self._item = str(os.urandom(30))
90         if item is not None:
91             self._item = item
92         self._ref = {}
93         if ref is not None:
94             self._ref = ref
95         if ref is None and item is None:
96             self._ref[self._item] = ""
97         if source:
98             self.source = source
99         super(JsonUnit, self).__init__(source)
100 
101     def getsource(self):
102         return self.target
103 
104     def setsource(self, source):
105         self.target = source
106     source = property(getsource, setsource)
107 
108     def gettarget(self):
109 
110         def change_type(value):
111             if isinstance(value, bool):
112                 return str(value)
113             return value
114 
115         if isinstance(self._ref, list):
116             return change_type(self._ref[self._item])
117         elif isinstance(self._ref, dict):
118             return change_type(self._ref[self._item])
119 
120     def settarget(self, target):
121 
122         def change_type(oldvalue, newvalue):
123             if isinstance(oldvalue, bool):
124                 newvalue = bool(newvalue)
125             return newvalue
126 
127         if isinstance(self._ref, list):
128             self._ref[int(self._item)] = change_type(self._ref[int(self._item)],
129                                                      target)
130         elif isinstance(self._ref, dict):
131             self._ref[self._item] = change_type(self._ref[self._item], target)
132         else:
133             raise ValueError("We don't know how to handle:\n"
134                              "Type: %s\n"
135                              "Value: %s" % (type(self._ref), target))
136     target = property(gettarget, settarget)
137 
138     def setid(self, value):
139         self._id = value
140 
141     def getid(self):
142         return self._id
143 
144     def getlocations(self):
145         return [self.getid()]
146 
147 
148 class JsonFile(base.TranslationStore):
149     """A JSON file"""
150     UnitClass = JsonUnit
151 
152     def __init__(self, inputfile=None, filter=None, **kwargs):
153         """construct a JSON file, optionally reading in from inputfile."""
154         super(JsonFile, self).__init__(**kwargs)
155         self._filter = filter
156         self.filename = ''
157         self._file = u''
158         if inputfile is not None:
159             self.parse(inputfile)
160 
161     def serialize(self, out):
162         units = {}
163         for unit in self.unit_iter():
164             path = unit.getid().lstrip('.')
165             units[path] = unit.target
166         out.write(json.dumps(units, sort_keys=True, separators=(',', ': '),
167                              indent=4, ensure_ascii=False).encode(self.encoding))
168         out.write(b'\n')
169 
170     def _extract_translatables(self, data, stop=None, prev="", name_node=None,
171                                name_last_node=None, last_node=None):
172         """Recursive function to extract items from the data files
173 
174         :param data: the current branch to walk down
175         :param stop: a list of leaves to extract or None to extract everything
176         :param prev: the heirarchy of the tree at this iteration
177         :param name_node:
178         :param name_last_node: the name of the last node
179         :param last_node: the last list or dict
180         """
181         if isinstance(data, dict):
182             for k, v in six.iteritems(data):
183                 for x in self._extract_translatables(v, stop,
184                                                           "%s.%s" % (prev, k),
185                                                           k, None, data):
186                     yield x
187         elif isinstance(data, list):
188             for i, item in enumerate(data):
189                 for x in self._extract_translatables(item, stop,
190                                                           "%s[%s]" % (prev, i),
191                                                           i, name_node, data):
192                     yield x
193         # apply filter
194         elif (stop is None or
195               (isinstance(last_node, dict) and name_node in stop) or
196               (isinstance(last_node, list) and name_last_node in stop)):
197 
198             if isinstance(data, six.string_types):
199                 yield (prev, data, last_node, name_node)
200             elif isinstance(data, bool):
201                 yield (prev, str(data), last_node, name_node)
202             elif data is None:
203                 pass
204             else:
205                 raise ValueError("We don't handle these values:\n"
206                                  "Type: %s\n"
207                                  "Data: %s\n"
208                                  "Previous: %s" % (type(data), data, prev))
209 
210     def parse(self, input):
211         """parse the given file or file source string"""
212         if hasattr(input, 'name'):
213             self.filename = input.name
214         elif not getattr(self, 'filename', ''):
215             self.filename = ''
216         if hasattr(input, "read"):
217             src = input.read()
218             input.close()
219             input = src
220         if isinstance(input, bytes):
221             input = input.decode('utf-8')
222         try:
223             if OrderedDict is not None:
224                 self._file = json.loads(input, object_pairs_hook=OrderedDict)
225             else:
226                 # object_pairs_hook is not present in Python 2.6
227                 self._file = json.loads(input)
228         except ValueError as e:
229             raise base.ParseError(e.message)
230 
231         for k, data, ref, item in self._extract_translatables(self._file,
232                                                 stop=self._filter):
233             unit = self.UnitClass(data, ref, item)
234             unit.setid(k)
235             self.addunit(unit)
236
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/translate/storage/jsonl10n.py b/translate/storage/jsonl10n.py
--- a/translate/storage/jsonl10n.py
+++ b/translate/storage/jsonl10n.py
@@ -64,7 +64,6 @@
 
 - Handle ``\u`` and other escapes in Unicode
 - Manage data type storage and conversion. True --> "True" --> True
-- Sort the extracted data to the order of the JSON file
 
 """
 
@@ -159,11 +158,14 @@
             self.parse(inputfile)
 
     def serialize(self, out):
-        units = {}
+        if OrderedDict is not None:
+            units = OrderedDict()
+        else:
+            units = {}
         for unit in self.unit_iter():
             path = unit.getid().lstrip('.')
             units[path] = unit.target
-        out.write(json.dumps(units, sort_keys=True, separators=(',', ': '),
+        out.write(json.dumps(units, separators=(',', ': '),
                              indent=4, ensure_ascii=False).encode(self.encoding))
         out.write(b'\n')

{"golden_diff": "diff --git a/translate/storage/jsonl10n.py b/translate/storage/jsonl10n.py\n--- a/translate/storage/jsonl10n.py\n+++ b/translate/storage/jsonl10n.py\n@@ -64,7 +64,6 @@\n \n - Handle ``\\u`` and other escapes in Unicode\n - Manage data type storage and conversion. True --> \"True\" --> True\n-- Sort the extracted data to the order of the JSON file\n \n \"\"\"\n \n@@ -159,11 +158,14 @@\n             self.parse(inputfile)\n \n     def serialize(self, out):\n-        units = {}\n+        if OrderedDict is not None:\n+            units = OrderedDict()\n+        else:\n+            units = {}\n         for unit in self.unit_iter():\n             path = unit.getid().lstrip('.')\n             units[path] = unit.target\n-        out.write(json.dumps(units, sort_keys=True, separators=(',', ': '),\n+        out.write(json.dumps(units, separators=(',', ': '),\n                              indent=4, ensure_ascii=False).encode(self.encoding))\n         out.write(b'\\n')\n", "issue": "json2po output strings in wrong order\nRunning `json2po` outputs a valid PO files, but the strings are in the wrong order. I\u2019m not sure exactly _which_ order it is, but is _neither_ the original order, the reverse order or alphabetically. Here\u2019s an example JSON file:\n\n``` json\n{\n    \"foo\": \"foo\",\n    \"bar\": \"bar\",\n    \"baz\": \"baz\"\n}\n```\n\nRunning `json2po` on this file results in the following (with a PO file header):\n\n``` po\n#: .baz\nmsgid \"baz\"\nmsgstr \"\"\n\n#: .foo\nmsgid \"foo\"\nmsgstr \"\"\n\n#: .bar\nmsgid \"bar\"\nmsgstr \"\"\n```\n\nHaving the strings in a different order than in the original file makes it much harder to correctly translate the file, as one loses context.\n\nI observe this bug both in version 1.13.0 and 1.14.0-rc1.\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright 2007,2009-2011 Zuza Software Foundation\n#\n# This file is part of the Translate Toolkit.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 2 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, see <http://www.gnu.org/licenses/>.\n\nr\"\"\"Class that manages JSON data files for translation\n\nJSON is an acronym for JavaScript Object Notation, it is an open standard\ndesigned for human-readable data interchange.\n\nJSON basic types:\n\n- Number (integer or real)\n- String (double-quoted Unicode with backslash escaping)\n- Boolean (true or false)\n- Array (an ordered sequence of values, comma-separated and enclosed in square\n  brackets)\n- Object (a collection of key:value pairs, comma-separated and enclosed in\n  curly braces)\n- null\n\nExample:\n\n.. code-block:: json\n\n   {\n        \"firstName\": \"John\",\n        \"lastName\": \"Smith\",\n        \"age\": 25,\n        \"address\": {\n            \"streetAddress\": \"21 2nd Street\",\n            \"city\": \"New York\",\n            \"state\": \"NY\",\n            \"postalCode\": \"10021\"\n        },\n        \"phoneNumber\": [\n            {\n              \"type\": \"home\",\n              \"number\": \"212 555-1234\"\n            },\n            {\n              \"type\": \"fax\",\n              \"number\": \"646 555-4567\"\n            }\n        ]\n   }\n\n\nTODO:\n\n- Handle ``\\u`` and other escapes in Unicode\n- Manage data type storage and conversion. True --> \"True\" --> True\n- Sort the extracted data to the order of the JSON file\n\n\"\"\"\n\nimport json\nimport os\ntry:\n    from collections import OrderedDict\nexcept ImportError:\n    # Python 2.6 does not have OrderedDict and also can't use it in\n    # json.loads()\n    OrderedDict = None\nimport six\n\nfrom translate.storage import base\n\n\nclass JsonUnit(base.TranslationUnit):\n    \"\"\"A JSON entry\"\"\"\n\n    def __init__(self, source=None, ref=None, item=None, **kwargs):\n        self._id = None\n        self._item = str(os.urandom(30))\n        if item is not None:\n            self._item = item\n        self._ref = {}\n        if ref is not None:\n            self._ref = ref\n        if ref is None and item is None:\n            self._ref[self._item] = \"\"\n        if source:\n            self.source = source\n        super(JsonUnit, self).__init__(source)\n\n    def getsource(self):\n        return self.target\n\n    def setsource(self, source):\n        self.target = source\n    source = property(getsource, setsource)\n\n    def gettarget(self):\n\n        def change_type(value):\n            if isinstance(value, bool):\n                return str(value)\n            return value\n\n        if isinstance(self._ref, list):\n            return change_type(self._ref[self._item])\n        elif isinstance(self._ref, dict):\n            return change_type(self._ref[self._item])\n\n    def settarget(self, target):\n\n        def change_type(oldvalue, newvalue):\n            if isinstance(oldvalue, bool):\n                newvalue = bool(newvalue)\n            return newvalue\n\n        if isinstance(self._ref, list):\n            self._ref[int(self._item)] = change_type(self._ref[int(self._item)],\n                                                     target)\n        elif isinstance(self._ref, dict):\n            self._ref[self._item] = change_type(self._ref[self._item], target)\n        else:\n            raise ValueError(\"We don't know how to handle:\\n\"\n                             \"Type: %s\\n\"\n                             \"Value: %s\" % (type(self._ref), target))\n    target = property(gettarget, settarget)\n\n    def setid(self, value):\n        self._id = value\n\n    def getid(self):\n        return self._id\n\n    def getlocations(self):\n        return [self.getid()]\n\n\nclass JsonFile(base.TranslationStore):\n    \"\"\"A JSON file\"\"\"\n    UnitClass = JsonUnit\n\n    def __init__(self, inputfile=None, filter=None, **kwargs):\n        \"\"\"construct a JSON file, optionally reading in from inputfile.\"\"\"\n        super(JsonFile, self).__init__(**kwargs)\n        self._filter = filter\n        self.filename = ''\n        self._file = u''\n        if inputfile is not None:\n            self.parse(inputfile)\n\n    def serialize(self, out):\n        units = {}\n        for unit in self.unit_iter():\n            path = unit.getid().lstrip('.')\n            units[path] = unit.target\n        out.write(json.dumps(units, sort_keys=True, separators=(',', ': '),\n                             indent=4, ensure_ascii=False).encode(self.encoding))\n        out.write(b'\\n')\n\n    def _extract_translatables(self, data, stop=None, prev=\"\", name_node=None,\n                               name_last_node=None, last_node=None):\n        \"\"\"Recursive function to extract items from the data files\n\n        :param data: the current branch to walk down\n        :param stop: a list of leaves to extract or None to extract everything\n        :param prev: the heirarchy of the tree at this iteration\n        :param name_node:\n        :param name_last_node: the name of the last node\n        :param last_node: the last list or dict\n        \"\"\"\n        if isinstance(data, dict):\n            for k, v in six.iteritems(data):\n                for x in self._extract_translatables(v, stop,\n                                                          \"%s.%s\" % (prev, k),\n                                                          k, None, data):\n                    yield x\n        elif isinstance(data, list):\n            for i, item in enumerate(data):\n                for x in self._extract_translatables(item, stop,\n                                                          \"%s[%s]\" % (prev, i),\n                                                          i, name_node, data):\n                    yield x\n        # apply filter\n        elif (stop is None or\n              (isinstance(last_node, dict) and name_node in stop) or\n              (isinstance(last_node, list) and name_last_node in stop)):\n\n            if isinstance(data, six.string_types):\n                yield (prev, data, last_node, name_node)\n            elif isinstance(data, bool):\n                yield (prev, str(data), last_node, name_node)\n            elif data is None:\n                pass\n            else:\n                raise ValueError(\"We don't handle these values:\\n\"\n                                 \"Type: %s\\n\"\n                                 \"Data: %s\\n\"\n                                 \"Previous: %s\" % (type(data), data, prev))\n\n    def parse(self, input):\n        \"\"\"parse the given file or file source string\"\"\"\n        if hasattr(input, 'name'):\n            self.filename = input.name\n        elif not getattr(self, 'filename', ''):\n            self.filename = ''\n        if hasattr(input, \"read\"):\n            src = input.read()\n            input.close()\n            input = src\n        if isinstance(input, bytes):\n            input = input.decode('utf-8')\n        try:\n            if OrderedDict is not None:\n                self._file = json.loads(input, object_pairs_hook=OrderedDict)\n            else:\n                # object_pairs_hook is not present in Python 2.6\n                self._file = json.loads(input)\n        except ValueError as e:\n            raise base.ParseError(e.message)\n\n        for k, data, ref, item in self._extract_translatables(self._file,\n                                                stop=self._filter):\n            unit = self.UnitClass(data, ref, item)\n            unit.setid(k)\n            self.addunit(unit)\n", "path": "translate/storage/jsonl10n.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright 2007,2009-2011 Zuza Software Foundation\n#\n# This file is part of the Translate Toolkit.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 2 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, see <http://www.gnu.org/licenses/>.\n\nr\"\"\"Class that manages JSON data files for translation\n\nJSON is an acronym for JavaScript Object Notation, it is an open standard\ndesigned for human-readable data interchange.\n\nJSON basic types:\n\n- Number (integer or real)\n- String (double-quoted Unicode with backslash escaping)\n- Boolean (true or false)\n- Array (an ordered sequence of values, comma-separated and enclosed in square\n  brackets)\n- Object (a collection of key:value pairs, comma-separated and enclosed in\n  curly braces)\n- null\n\nExample:\n\n.. code-block:: json\n\n   {\n        \"firstName\": \"John\",\n        \"lastName\": \"Smith\",\n        \"age\": 25,\n        \"address\": {\n            \"streetAddress\": \"21 2nd Street\",\n            \"city\": \"New York\",\n            \"state\": \"NY\",\n            \"postalCode\": \"10021\"\n        },\n        \"phoneNumber\": [\n            {\n              \"type\": \"home\",\n              \"number\": \"212 555-1234\"\n            },\n            {\n              \"type\": \"fax\",\n              \"number\": \"646 555-4567\"\n            }\n        ]\n   }\n\n\nTODO:\n\n- Handle ``\\u`` and other escapes in Unicode\n- Manage data type storage and conversion. True --> \"True\" --> True\n\n\"\"\"\n\nimport json\nimport os\ntry:\n    from collections import OrderedDict\nexcept ImportError:\n    # Python 2.6 does not have OrderedDict and also can't use it in\n    # json.loads()\n    OrderedDict = None\nimport six\n\nfrom translate.storage import base\n\n\nclass JsonUnit(base.TranslationUnit):\n    \"\"\"A JSON entry\"\"\"\n\n    def __init__(self, source=None, ref=None, item=None, **kwargs):\n        self._id = None\n        self._item = str(os.urandom(30))\n        if item is not None:\n            self._item = item\n        self._ref = {}\n        if ref is not None:\n            self._ref = ref\n        if ref is None and item is None:\n            self._ref[self._item] = \"\"\n        if source:\n            self.source = source\n        super(JsonUnit, self).__init__(source)\n\n    def getsource(self):\n        return self.target\n\n    def setsource(self, source):\n        self.target = source\n    source = property(getsource, setsource)\n\n    def gettarget(self):\n\n        def change_type(value):\n            if isinstance(value, bool):\n                return str(value)\n            return value\n\n        if isinstance(self._ref, list):\n            return change_type(self._ref[self._item])\n        elif isinstance(self._ref, dict):\n            return change_type(self._ref[self._item])\n\n    def settarget(self, target):\n\n        def change_type(oldvalue, newvalue):\n            if isinstance(oldvalue, bool):\n                newvalue = bool(newvalue)\n            return newvalue\n\n        if isinstance(self._ref, list):\n            self._ref[int(self._item)] = change_type(self._ref[int(self._item)],\n                                                     target)\n        elif isinstance(self._ref, dict):\n            self._ref[self._item] = change_type(self._ref[self._item], target)\n        else:\n            raise ValueError(\"We don't know how to handle:\\n\"\n                             \"Type: %s\\n\"\n                             \"Value: %s\" % (type(self._ref), target))\n    target = property(gettarget, settarget)\n\n    def setid(self, value):\n        self._id = value\n\n    def getid(self):\n        return self._id\n\n    def getlocations(self):\n        return [self.getid()]\n\n\nclass JsonFile(base.TranslationStore):\n    \"\"\"A JSON file\"\"\"\n    UnitClass = JsonUnit\n\n    def __init__(self, inputfile=None, filter=None, **kwargs):\n        \"\"\"construct a JSON file, optionally reading in from inputfile.\"\"\"\n        super(JsonFile, self).__init__(**kwargs)\n        self._filter = filter\n        self.filename = ''\n        self._file = u''\n        if inputfile is not None:\n            self.parse(inputfile)\n\n    def serialize(self, out):\n        if OrderedDict is not None:\n            units = OrderedDict()\n        else:\n            units = {}\n        for unit in self.unit_iter():\n            path = unit.getid().lstrip('.')\n            units[path] = unit.target\n        out.write(json.dumps(units, separators=(',', ': '),\n                             indent=4, ensure_ascii=False).encode(self.encoding))\n        out.write(b'\\n')\n\n    def _extract_translatables(self, data, stop=None, prev=\"\", name_node=None,\n                               name_last_node=None, last_node=None):\n        \"\"\"Recursive function to extract items from the data files\n\n        :param data: the current branch to walk down\n        :param stop: a list of leaves to extract or None to extract everything\n        :param prev: the heirarchy of the tree at this iteration\n        :param name_node:\n        :param name_last_node: the name of the last node\n        :param last_node: the last list or dict\n        \"\"\"\n        if isinstance(data, dict):\n            for k, v in six.iteritems(data):\n                for x in self._extract_translatables(v, stop,\n                                                          \"%s.%s\" % (prev, k),\n                                                          k, None, data):\n                    yield x\n        elif isinstance(data, list):\n            for i, item in enumerate(data):\n                for x in self._extract_translatables(item, stop,\n                                                          \"%s[%s]\" % (prev, i),\n                                                          i, name_node, data):\n                    yield x\n        # apply filter\n        elif (stop is None or\n              (isinstance(last_node, dict) and name_node in stop) or\n              (isinstance(last_node, list) and name_last_node in stop)):\n\n            if isinstance(data, six.string_types):\n                yield (prev, data, last_node, name_node)\n            elif isinstance(data, bool):\n                yield (prev, str(data), last_node, name_node)\n            elif data is None:\n                pass\n            else:\n                raise ValueError(\"We don't handle these values:\\n\"\n                                 \"Type: %s\\n\"\n                                 \"Data: %s\\n\"\n                                 \"Previous: %s\" % (type(data), data, prev))\n\n    def parse(self, input):\n        \"\"\"parse the given file or file source string\"\"\"\n        if hasattr(input, 'name'):\n            self.filename = input.name\n        elif not getattr(self, 'filename', ''):\n            self.filename = ''\n        if hasattr(input, \"read\"):\n            src = input.read()\n            input.close()\n            input = src\n        if isinstance(input, bytes):\n            input = input.decode('utf-8')\n        try:\n            if OrderedDict is not None:\n                self._file = json.loads(input, object_pairs_hook=OrderedDict)\n            else:\n                # object_pairs_hook is not present in Python 2.6\n                self._file = json.loads(input)\n        except ValueError as e:\n            raise base.ParseError(e.message)\n\n        for k, data, ref, item in self._extract_translatables(self._file,\n                                                stop=self._filter):\n            unit = self.UnitClass(data, ref, item)\n            unit.setid(k)\n            self.addunit(unit)\n", "path": "translate/storage/jsonl10n.py"}]}