Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR should fix issue #69 and #72.
It can correctly flatten the data which has a more than 10 items array. (#69)
It can correctly flatten the data which has an array including another array. (#72)
Bug Fixes/New Features
Fixes #69
Fixes #72
How to Verify
Side Effects
Resolves
Fixes #69
Fixes #72
Tests
Case 1.
data = '''
{
"header": "header a",
"orderItems":[
{"itemLineNumber":1, "itemQuantity":468 },
{"itemLineNumber":2, "itemQuantity":414 },
{ "itemLineNumber":3, "itemQuantity":24 },
{ "itemLineNumber":4, "itemQuantity":24 },
{ "itemLineNumber":5, "itemQuantity":36 },
{ "itemLineNumber":6, "itemQuantity":24 },
{ "itemLineNumber":7, "itemQuantity":84 },
{ "itemLineNumber":8, "itemQuantity":60},
{"itemLineNumber":9,"itemQuantity":42 },
{ "itemLineNumber":10, "itemQuantity":84 },
{"itemLineNumber":11, "itemQuantity":12 },
{ "itemLineNumber":12, "itemQuantity":12 }]
}
'''
result:
[{'orderItems.itemQuantity': 468, 'orderItems.itemLineNumber': 1, 'header': 'header a'}, {'orderItems.itemQuantity': 414, 'orderItems.itemLineNumber': 2, 'header': 'header a'}, {'orderItems.itemQuantity': 12, 'orderItems.itemLineNumber': 11, 'header': 'header a'}, {'orderItems.itemQuantity': 12, 'orderItems.itemLineNumber': 12, 'header': 'header a'}, {'orderItems.itemQuantity': 24, 'orderItems.itemLineNumber': 3, 'header': 'header a'}, {'orderItems.itemQuantity': 24, 'orderItems.itemLineNumber': 4, 'header': 'header a'}, {'orderItems.itemQuantity': 36, 'orderItems.itemLineNumber': 5, 'header': 'header a'}, {'orderItems.itemQuantity': 24, 'orderItems.itemLineNumber': 6, 'header': 'header a'}, {'orderItems.itemQuantity': 84, 'orderItems.itemLineNumber': 7, 'header': 'header a'}, {'orderItems.itemQuantity': 60, 'orderItems.itemLineNumber': 8, 'header': 'header a'}, {'orderItems.itemQuantity': 42, 'orderItems.itemLineNumber': 9, 'header': 'header a'}, {'orderItems.itemQuantity': 84, 'orderItems.itemLineNumber': 10, 'header': 'header a'}]
Case 2.
data = '''
{"header": "header a",
"item": [{"itemLineNumber": 1}, {"itemLineNumber": 2}],
"containerInfo":
[{ "containerId":"A",
"containerItems":[{"itemSKU":1}]},
{"containerId":"B",
"containerItems":[{"itemSKU":2}]},
{"containerId":"C",
"containerItems":[{"itemSKU":3}]},
{"containerId":"D",
"containerItems":[{"itemSKU":4}]},
{"containerId":"E",
"containerItems":[{"itemSKU":5}]}]}
'''
result:
[{'item': 1, 'containerInfo.containerId': 'A', 'header': 'header a', 'containerInfo.containerItems': 1}, {'item': 2, 'containerInfo.containerId': 'A', 'header': 'header a', 'containerInfo.containerItems': 1}, {'item': 1, 'containerInfo.containerId': 'B', 'header': 'header a', 'containerInfo.containerItems': 2}, {'item': 2, 'containerInfo.containerId': 'B', 'header': 'header a', 'containerInfo.containerItems': 2}, {'item': 1, 'containerInfo.containerId': 'C', 'header': 'header a', 'containerInfo.containerItems': 3}, {'item': 2, 'containerInfo.containerId': 'C', 'header': 'header a', 'containerInfo.containerItems': 3}, {'item': 1, 'containerInfo.containerId': 'D', 'header': 'header a', 'containerInfo.containerItems': 4}, {'item': 2, 'containerInfo.containerId': 'D', 'header': 'header a', 'containerInfo.containerItems': 4}, {'item': 1, 'containerInfo.containerId': 'E', 'header': 'header a', 'containerInfo.containerItems': 5}, {'item': 2, 'containerInfo.containerId': 'E', 'header': 'header a', 'containerInfo.containerItems': 5}]
Code Reviewer(s)
@amirziai , @amir-ziai-zefr