Fix an array parse error

When parse an array with config `keep_arrays_single_line = true`, `output_json.replace(m, replacement)` will replace more than once if another array is a subset of current.
Example:
```{"a": [1],"b": [2,3,1]}```
should be parsed like: 
```
{
    "a": [1],
    "b": [2, 3, 1]
}
```
but actually got 
```
{
  "a": [1],
  "b": [
    2,
    3,1]
}
```
This commit is contained in:
mrliaocn 2019-12-23 16:59:39 +08:00 committed by GitHub
parent 77a8fbab60
commit 210d6a3a45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -96,7 +96,7 @@ class PrettyJsonBaseCommand:
replacement = join_separator.join(items)
# if line not gets too long, replace with single line
if len(replacement) <= s.get("max_arrays_line_length", 120):
output_json = output_json.replace(m, replacement)
output_json = output_json.replace(m, replacement, 1)
return output_json