Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release: 0.0.110 #304

Merged
merged 2 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions openformats/formats/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ def parse(self, content, **kwargs):
raise ParseError(six.text_type(e))
self._order = count()
self._extract(parsed)

if not self.stringset and self.name == "STRUCTURED_JSON":
raise ParseError('No strings could be extracted')

self.transcriber.copy_until(len(source))

return self.transcriber.get_destination(), self.stringset
Expand Down Expand Up @@ -146,9 +150,6 @@ def _extract(self, parsed, nest=None):
else:
raise ParseError("Invalid JSON")

if not self.stringset and self.name == "STRUCTURED_JSON":
raise ParseError('No strings could be extracted')

def _create_openstring(self, key, value, value_position):
"""Return a new OpenString based on the given key and value
and update the transcriber accordingly based on the provided position.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,14 +679,14 @@ def test_unescaped(self):
self.maxDiff = None
self.assertEqual(compiled, expected_compilation)

def test_empty_string(self):
def test_empty_strings(self):
source = u"""
{
"a": {
"string": ""
},
"b": {
"string": "x0x0",
"string": "",
"character_limit": 35
}
}
Expand Down
Loading