Skip to content

Commit fa9ecd5

Browse files
committed
Add another test case to test id None at diff levels
1 parent bc22a55 commit fa9ecd5

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

pandas/tests/io/json/test_normalize.py

+27
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,33 @@ def test_nonetype_dropping(self):
376376

377377
assert result == expected
378378

379+
def test_nonetype_top_level_bottom_level(self):
380+
# GH21158: If inner level json has a key with a null value
381+
# make sure it doesnt do a new_d.pop twice and except
382+
data = {
383+
"id": None,
384+
"location": {
385+
"country": {
386+
"state": {
387+
"id": None,
388+
"town.info": {
389+
"id": None,
390+
"region": None,
391+
"x": 49.151580810546875,
392+
"y": -33.148521423339844,
393+
"z": 27.572303771972656}}}
394+
}
395+
}
396+
result = nested_to_record(data)
397+
expected = {
398+
'location.country.state.id': None,
399+
'location.country.state.town.info.id': None,
400+
'location.country.state.town.info.region': None,
401+
'location.country.state.town.info.x': 49.151580810546875,
402+
'location.country.state.town.info.y': -33.148521423339844,
403+
'location.country.state.town.info.z': 27.572303771972656}
404+
assert result == expected
405+
379406
def test_nonetype_multiple_levels(self):
380407
# GH21158: If inner level json has a key with a null value
381408
# make sure it doesnt do a new_d.pop twice and except

0 commit comments

Comments
 (0)