Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Mateusz Pawlik
ted-datasets
Commits
69b520c1
Commit
69b520c1
authored
Jun 14, 2018
by
Mateusz Pawlik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added removal of the null character.
Weird stuff that caused errors in parsing bracket notation in C++.
parent
3a6c0e07
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
python_ast/parse_json.py
python_ast/parse_json.py
+3
-1
No files found.
python_ast/parse_json.py
View file @
69b520c1
...
...
@@ -14,7 +14,9 @@ import json
def
print_tree
(
json_tree
,
index
):
print
(
'{'
+
json_tree
[
index
][
'type'
],
end
=
''
)
if
'value'
in
json_tree
[
index
]:
print
(
'{'
+
json_tree
[
index
][
'value'
].
replace
(
'
\r
'
,
''
).
replace
(
'
\n
'
,
''
).
replace
(
'
\t
'
,
''
).
strip
().
translate
(
str
.
maketrans
({
"{"
:
r
"\{"
,
# \x00 is a null character (https://en.wikipedia.org/wiki/Null_character)
# it caused endless loop / SEGFAULT while parsing a tree in bracket notation
print
(
'{'
+
json_tree
[
index
][
'value'
].
replace
(
'
\r
'
,
''
).
replace
(
'
\n
'
,
''
).
replace
(
'
\t
'
,
''
).
replace
(
'
\x00
'
,
''
).
strip
().
translate
(
str
.
maketrans
({
"{"
:
r
"\{"
,
"}"
:
r
"\}"
,
"
\\
"
:
r
"\\"
}))
+
'}'
,
end
=
''
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment