Skip to content

Commit 741b170

Browse files
Merge pull request #136 from alliander-opensource/feature/json-new-line
Add a new line to the end of compact json files
2 parents eaca61a + e727ea7 commit 741b170

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ jobs:
3838
run: |
3939
sudo apt-get update
4040
sudo apt-get install -y ninja-build
41+
- name: Enable brew
42+
run: |
43+
echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
4144
- name: Install C++ dependencies
4245
run: |
4346
brew install boost eigen nlohmann-json doctest

.github/workflows/sonar.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ jobs:
3636
run: |
3737
sudo apt-get update
3838
sudo apt-get install -y ninja-build lcov gcovr
39+
- name: Enable brew
40+
run: |
41+
echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
3942
- name: Install C++ dependencies
4043
run: |
4144
brew install boost eigen nlohmann-json doctest

src/power_grid_model/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,4 +553,4 @@ def compact_json_dump(data: Any, io_stream: IO[str], indent: int, max_level: int
553553
io_stream.write("\n")
554554
compact_json_dump(obj, io_stream, indent, max_level, level + 2)
555555
io_stream.write(",\n" if i < n_obj else "\n")
556-
io_stream.write(tab + "}")
556+
io_stream.write(tab + "}\n")

tests/unit/test_utils.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ def test_compact_json_dump():
184184
== """{
185185
"node": [{"id": 1, "x": 2}, {"id": 3, "x": 4}],
186186
"line": [{"id": 5, "x": 6}, {"id": 7, "x": {"y": 8.1, "z": 8.2}}]
187-
}"""
187+
}
188+
"""
188189
)
189190

190191
string_stream = io.StringIO()
@@ -196,7 +197,8 @@ def test_compact_json_dump():
196197
[{"id": 1, "x": 2}, {"id": 3, "x": 4}],
197198
"line":
198199
[{"id": 5, "x": 6}, {"id": 7, "x": {"y": 8.1, "z": 8.2}}]
199-
}"""
200+
}
201+
"""
200202
)
201203

202204
string_stream = io.StringIO()
@@ -214,7 +216,8 @@ def test_compact_json_dump():
214216
{"id": 5, "x": 6},
215217
{"id": 7, "x": {"y": 8.1, "z": 8.2}}
216218
]
217-
}"""
219+
}
220+
"""
218221
)
219222

220223

@@ -243,7 +246,9 @@ def test_compact_json_dump_deep():
243246
"x": 2,
244247
"y": 3
245248
}
246-
}"""
249+
250+
}
251+
"""
247252
)
248253

249254

@@ -273,14 +278,16 @@ def test_compact_json_dump_batch():
273278
{"id": 5, "x": 6},
274279
{"id": 7, "x": {"y": 8.1, "z": 8.2}}
275280
]
276-
},
281+
}
282+
,
277283
{
278284
"line":
279285
[
280286
{"id": 9, "x": 10},
281287
{"id": 11, "x": 12}
282288
]
283289
}
290+
284291
]"""
285292
)
286293

0 commit comments

Comments
 (0)